import 'package:flutter/material.dart'; class Sport extends StatelessWidget { final List _curSport = ['FootBall', Colors.green]; final List colorList = [ const Item("FootBall", Colors.red), const Item("Soccer", Colors.pinkAccent), const Item('Baseball', Colors.yellow), ]; @override Widget build(BuildContext context) { Item selectedSport; return StatefulBuilder( builder: (context, StateSetter setState) => Scaffold( appBar: AppBar( title: DropdownButton( value: selectedSport, icon: Icon(Icons.arrow_drop_down), iconSize: 24, style: TextStyle(color: Colors.black), iconEnabledColor: Colors.white, onChanged: (Item value) { setState(() { selectedSport = value; _curSport[0] = selectedSport.name; _curSport[1] = selectedSport.color; }); }, items: colorList.map>((Item item) { return DropdownMenuItem( value: item, child: SizedBox( width: 100, child: Text(item.name), ), ); }).toList(), ), backgroundColor: _curSport[1], ), body: Center( child: Text("Sports Page Body"), ), ), ); } } class Item { const Item(this.name, this.color); final String name; final Color color; }