The official example of Flutter for using a Theme and extend/override it, does not work as shown.

I used flutter upgrade and flutter doctor, so my Flutter is the newest and workes fine. And the android emulator also works fine I guess.
I also restarted my PC, but it did not help.

I used the code from this site: https://flutter.dev/docs/cookbook/design/themes

The floatingActionButton should be yellow, but my button is cyan. So the override did not work. (I could add a picture if needed, but I think my Problem is clear. )

theme: ThemeData(
        // Define the default Brightness and Colors
        brightness: Brightness.dark,
        primaryColor: Colors.lightBlue[800],
        accentColor: Colors.cyan[600],

        // Define the default Font Family
        fontFamily: 'Montserrat',

        // Define the default TextTheme. Use this to specify the default
        // text styling for headlines, titles, bodies of text, and more.
        textTheme: TextTheme(
          headline: TextStyle(fontSize: 72.0, fontWeight: FontWeight.bold),
          title: TextStyle(fontSize: 36.0, fontStyle: FontStyle.italic),
          body1: TextStyle(fontSize: 14.0, fontFamily: 'Hind'),
        ),
      ),
floatingActionButton: Theme(
        data: Theme.of(context).copyWith(accentColor: Colors.yellow),
        child: FloatingActionButton(
          onPressed: null,
          child: Icon(Icons.add),
        ),
      ),

1 Answers

0
Haroun Hajem On

Try running Flutter clean and re-run your app.