skip to Main Content

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

Answers


  1. 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(),
          );
        }
      }
    

    `

    Login or Signup to reply.
  2. This code should work, try it..

      class MyApp extends StatelessWidget {
              @override
              Widget build(BuildContext context) {
                return MaterialApp(
                  theme: ThemeData.light(useMaterial3: true),
                  body: MyHomePage(),
                );
              }
            }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search