flutter wont update widgets to material design 3

405 Views Asked by At

My flutter app wont use materal desing 3 after adding useMaterial3:true in theme

I added the flag according to the the blog and material design website(flutter)

2

There are 2 best solutions below

0
On

try this code it should work fine . `

void main() {
  runApp(
    const MyApp(),
  );
}
class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
      return MaterialApp(
        debugShowCheckedModeBanner: false,
        theme: ThemeData(useMaterial3: true),
        home: const HomePage(),
      );
    }
  }

`

0
On

This code should work, try it..

  class MyApp extends StatelessWidget {
          @override
          Widget build(BuildContext context) {
            return MaterialApp(
              theme: ThemeData.light(useMaterial3: true),
              body: MyHomePage(),
            );
          }
        }