"theme: ThemeData..." apparently ignored starting with Flutter 2.5.0

Viewed 1621

I'm working through the startup_namer tutorial example from flutter.dev. Here's the definition of MyApp:

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Startup Name Generator',
        theme: ThemeData(
          // Add the 3 lines from here...
          primaryColor: Colors.white,
        ), // ... to here.
        home: RandomWords());
  }
}

It used to be that when I ran the app, the title bar would be white. But now, it retains the default (blue) theme. Looks like either ThemeData or at least primaryColor are being ignored. Does anyone know how to fix this? Thank you.

2 Answers

Checkout this link and this quote from the Flutter-Team:

The ThemeData accentColor, accentColorBrightness, accentIconTheme and accentTextTheme properties have been deprecated.

The Material Design spec no longer specifies or uses an “accent” color for the Material components. The default values for component colors are derived from the overall theme’s color scheme. The ColorScheme’s secondary color is now typically used instead of accentColor and the onSecondary color is used when a contrasting color is needed.

Also checkout the migration guide.

Regarding your appBar problem do this within the ThemeData():

  appBarTheme: AppBarTheme(backgroundColor: Colors.white),
Related