Generate random colors
return new RaisedButton( padding: EdgeInsets.symmetric(vertical: 30.0), color: Colors.primaries random List <blue,green>,
The Random class comes with a method name nextInt that can generate a random integer in the range from 0, inclusive, to a given max value, exclusive. You can make a random color like this: Color _randomColor = Colors. primaries[Random().
Row does not have any default attribute to set background color. So what we do then? Just wrap Row with other widgets, give color to them and it will affect in Row's background. Wraping a widget with other widget is very common in Flutter :-).
This is my way to get a random color:
Color((math.Random().nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0)
Note:
This import is required.
import 'dart:math' as math;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With