ThemeData

ThemeData is a class in Flutter that provides a way to define a theme for your application. The theme consists of colors, fonts, and other visual elements that define the look and feel of your app.

Here is a simple code example of how to use ThemeData in Flutter:

import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      theme: ThemeData(
        primaryColor: Colors.blue,
        accentColor: Colors.red,
        fontFamily: 'Roboto',
      ),
      home: MyHomePage(),
    ),
  );
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('My App'),
      ),
      body: Center(
        child: Text(
          'Hello, world!',
          style: Theme.of(context).textTheme.headline4,
        ),
      ),
    );
  }
}

In this example, we define a theme for our app using the ThemeData class. We set the primary color to blue, the accent color to red, and the font family to Roboto. We then use this theme in our app by wrapping our MaterialApp widget with it.

We can then access the theme data in any of our widgets using the Theme.of(context) method. This allows us to easily apply the theme to our app's visual elements.

That's it! With just a few lines of code, we can define a theme for our app and use it to create a consistent look and feel throughout our entire application.

Parameters

Here are some common parameters that can be set using ThemeData: