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>,
You can use
Random
class to do that:But if you want to change the color when button is pressed, you have to use a
StatefulWidget
. A simple example is like below:Also, there is a package called random_pk by pawankumar, that will give us random color each and every time your app's build method get called.
Another way to get tons of colors is using
Random
class withColor.fromARGB
orColor.fromRGBO
:If you use
Color.fromRGBO
:Fourth argument should be within
0.0
to1.0
and fortunately we have_random.nextDouble()
that gives a value between0.0
to1.0
randomly.By the way: