// import 'dart:math' as math; Color((math.Random().nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0) color: Colors.primaries[Random().nextInt(Colors.primaries.length)], or use package random_color 1.0.5Colors.primaries[Random().nextInt(Colors.primaries.length)],import 'dart:math'; color:Colors.primaries[Random().nextInt(Colors.primaries.length)],import 'dart:math'; import 'package:flutter/material.dart'; Color getRandomColor() { final random = Random(); return Color.fromRGBO( random.nextInt(256), random.nextInt(256), random.nextInt(256), 1.0, ); }Random random = Random(); Color tempcol = Color.fromRGBO( random.nextInt(255), random.nextInt(255), random.nextInt(255), 1, ); //tempcol is random color