Group Group Group Group Group Group Group Group Group

ThemeData for RecipeApp

Hey, hope someone can help.

I’ve been working through the first section of Flutter Apprentice and created the Recipe App. I followed the instructions and created the app, everything worked fine except for the Theme. The colors on the iOS Simulator wouldn’t changed to the grey/black scheme. After I’d completed the whole app I did some digging around on the flutter.dev site, read the docs on ThemeData and changed the code to this…

class RecipeApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Recipe Calculator',
      theme: ThemeData(
          primaryColor: Colors.grey,
          secondaryHeaderColor: Colors.black,
      ),
      home: MyHomePage(title: 'Recipe Calculator'),
    );
  }
}

It works, the colors have updated as expected. It seems a lot simpler and less code, but I’m wondering if there is a disadvantage to using this ‘new’ code? Have I miss something?

1 Like

I’m too facing the same issue.

hi.
I was a same problem with my device (motorola one vision).
For solution, a run a flutter upgrade.

running the flutter upgrade didn’t work

@carlstep333 have you tried doing a flutter clean? If not, from your IDE’s terminal, be at the top level of your project and run flutter clean && flutter pub get. This will perform the clean and then run pub get. Then re-run.

Also, have you tried deleting the app from your simulator and then re-running it?

I was having this same issue. The solution provided by OP worked for me and so did

flutter upgrade

and

‘flutter clean && flutter pub get’