Loïc Fonkam
Loïc Fonkam

Reputation: 2340

How to toggle dark and white mode in flutter using filters

In CSS a dark mode can be toggle using filter: invert(1) hue-rotate9180deg).

Is there a way to achieve that in flutter?

Upvotes: 0

Views: 100

Answers (1)

NiiLx
NiiLx

Reputation: 676

Yeah there is simple trick for dark mode. take a global varible and use it anywhere to change the app theme to dark to light or light to dark. Add this to your MaterialApp. Here is a example:

MaterialApp(
      title: 'Flutter App',
      debugShowCheckedModeBanner: false,
      theme: ThemeData.light(),
      darkTheme: ProjectResource.darkTheme? ThemeData.dark():ThemeData.light(),
      
     home: Homepage(title: 'Homepage',notifyParent: refresh,),
    );

Upvotes: 1

Related Questions