DEV Community

Pere Sola
Pere Sola

Posted on

How to use a hex color in Material App theme?

You may have this:

theme: ThemeData( primarySwatch: Colors.green, ), 
Enter fullscreen mode Exit fullscreen mode

And you may want to use a hex color. You can do it like that:

theme: Theme.of(context).copyWith( colorScheme: Theme.of(context).colorScheme.copyWith( primary: const Color(0xFFC0CDB5), ), ), 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)