Question Detail

type 'color' is not a subtype of type 'materialcolor' flutter

4 years ago Views 5379 Visit Post Reply

When I try to set Colors.black primarySwatch color, I got error: type 'Color' is not a subtype of type 'MaterialColor' in flutter. 

How to solve Color is not a subtype of MaterialColor?


Thread Reply

Correct Answer

alex levine

- 4 years ago

theme: ThemeData(

primarySwatch: Colors.black

),

thats way you are getting error type 'Color' is not a subtype of type 'MaterialColor'

primarySwatch is a banch of multiple colors for deffrant part like primarySwatch has color for status bar Titlebar etc.
you are tring to set single colors for primarySwatch. 

if you want to setup deffrente colors for your own dont use primarySwatch

use,

primaryColor: Colors.black,
primaryColorLight: Colors.grey,
accentColor: Colors.blue,