Flutter › App Theming & Dark Mode

What is a ThemeData object in Flutter, and how does it let you define consistent colors, fonts, and styling across an entire application from a single central place?

Beginner

Answer

A ThemeData object holds a comprehensive set of visual styling values, including a color scheme, text styles, button styles, and many other visual properties, and by defining a single ThemeData object and passing it to your MaterialApp widget, every Material component throughout your entire app automatically picks up these consistent styling values, meaning you can change your app's overall look and feel by updating just one central place rather than manually restyling every single individual widget throughout the entire codebase.
MaterialApp(
  theme: ThemeData(
    primarySwatch: Colors.blue,
    fontFamily: 'Roboto',
  ),
  home: HomePage(),
)
Real-world example A company rebrands their app with a new primary brand color by simply updating the primarySwatch value within their single central ThemeData definition, instantly updating the color of buttons and other Material components throughout the entire app.

Common follow-ups: How do you access the current theme's values from within a specific widget's build method?;What is the difference between ThemeData and a custom design system built on top of it?