Home > Back-end >  How to change the `primary color` for ThemeData dark in flutter?
How to change the `primary color` for ThemeData dark in flutter?

Time:12-19

I am using flutter 2.8.0 to create a simple app. But when I am trying to change the primary color for the App it does not work with me.

This is the code I am working on:

class BMICalculator extends StatelessWidget {
  const BMICalculator({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark().copyWith(
        primaryColor: const Color(0xFF0A0E21),
        scaffoldBackgroundColor: const Color(0xFF0A0E21),
      ),
      home: const InputPage(),
    );
  }
}

CodePudding user response:

Use primarySwatch

theme: ThemeData(
primarySwatch: Colors.red,
),

CodePudding user response:

@Mrinal already mentioned you to use primarySwatch. Flutter team intended to build enter image description here

For more read this article article

  • Related