Home > Blockchain >  Theme: ThemeData() Flutter
Theme: ThemeData() Flutter

Time:11-03

I'm trying to use Theme but don't know what i'm doing wrong the color didn't change.need help :

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(primaryColor: Colors.green),
    );
  }

CodePudding user response:

You should use appBarTheme: AppBarTheme(), then do the changes as you like.

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
     theme: ThemeData(appBarTheme: AppBarTheme(color: Colors.green, elevation: 15)),
    );
  }
  • Related