Issue
I want to set the background Colors.yellow[700] in flutter,but when i add symbol "[]" or Colors.yellow.shade600, but i can't set the value for background. It shows error & the error is
The argument type 'MaterialColor' can't be assigned to the parameter type 'Paint'
Solution
If you want primarySwatch
with Colors.yellow[700]
as primaryColor
you would have to create your own MaterialColor
from color Colors.yellow[700]
like this
final Map<int, Color> _yellow700Map = {
50: Color(0xFFFFD7C2),
100: Colors.yellow[100],
200: Colors.yellow[200],
300: Colors.yellow[300],
400: Colors.yellow[400],
500: Colors.yellow[500],
600: Colors.yellow[600],
700: Colors.yellow[800],
800: Colors.yellow[900],
900: Colors.yellow[700],
};
final MaterialColor _yellow700Swatch =
MaterialColor(Colors.yellow[700].value, _yellow700Map);
and then add it as primarySwatch: _yellow700Swatch,
or if you want only your background to be Colors.yellow[700]
you can use canvasColor like this canvasColor: Colors.yellow[700],
.
Answered By - Yashawant