build method
- @override
- BuildContext context,
- ColorBuilder model
override
Builds the UI according to the state in model.
Implementation
@override
Widget build(BuildContext context, ColorBuilder model) => AlertDialog(
title: const Text("Pick a color"),
actions: [
TextButton(
child: const Text("Cancel"),
onPressed: () => Navigator.of(context).pop(),
),
ElevatedButton(
onPressed: () async {
final result = await model.setColor();
if (result && context.mounted) Navigator.of(context).pop();
},
child: const Text("Save"),
),
],
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
SegmentedButton(
style: SegmentedButton.styleFrom(
selectedBackgroundColor: Colors.transparent,
),
onSelectionChanged: model.updateColor,
emptySelectionAllowed: true,
selected: {model.color},
segments: [
ButtonSegment(
value: ProtoColor.RED,
icon: Container(
height: 48,
width: 48,
margin: const EdgeInsets.all(8),
color: Colors.red,
),
label: const Text("Red"),
),
ButtonSegment(
value: ProtoColor.GREEN,
icon: Container(
height: 48,
width: 48,
margin: const EdgeInsets.all(8),
color: Colors.green,
),
label: const Text("Green"),
),
ButtonSegment(
value: ProtoColor.BLUE,
icon: Container(
height: 48,
width: 48,
margin: const EdgeInsets.all(8),
color: Colors.blue,
),
label: const Text("Blue"),
),
],
),
const SizedBox(height: 16),
CheckboxListTile(
value: model.blink,
onChanged: model.updateBlink,
title: const Text("Blink"),
),
],
),
);