Generate random colors
return new RaisedButton(
padding: EdgeInsets.symmetric(vertical: 30.0),
color: Colors.primaries random List <blue,green>,
Generate random colors
return new RaisedButton(
padding: EdgeInsets.symmetric(vertical: 30.0),
color: Colors.primaries random List <blue,green>,
This will generate a different color for the button everytime the build method for the app is called
There is an in-built list of material colors in the Colors class. You can use it like below
e.g
Above is the simplest and fastest way to colorize your list with random colors. You don't need to maintain a list of colors.
To get random color I do the next:
Simplest and best suggested way to do this is:
Step 1: Add dependency in pubspec.yaml random_color: ^1.0.3
Step 2: Add import import 'package:random_color/random_color.dart';
Step 3: In "color" attribute write color: RandomColor().randomColor();
This is my way to get a random color:
We can use random class for that But there is a random_color plugin in the flutter that can help us for generating random color and also we can select high saturation colors with this code:
And light colors with this code:
For more options read this https://pub.dev/packages/random_color#-readme-tab-