changeColor function
Implementation
Future<Color?> changeColor(BuildContext context, Color selectedColor ) async {
return showDialog<Color>(
context: context,
//barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
Color color = selectedColor;
return AlertDialog(
title: const Text('Pick a color!'),
content: SingleChildScrollView(
child: ColorPicker(
pickerColor: selectedColor,
onColorChanged: (newColor){
color = newColor;
},
),
),
actions: <Widget>[
ElevatedButton(
child: const Text('Got it'),
onPressed: () {
Navigator.pop(context,color);
},
),
],
);
}
);
}