Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa committed Aug 21, 2022
1 parent 45c541a commit 9b1e8d4
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions example/lib/screens/forms/combobox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -310,18 +310,34 @@ EditableComboBox<int>(
color: colors[selectedColor],
),
]),
codeSnippet: '''// Green by default
codeSnippet: '''Map<String, Color> colors = { ... };
Color selectedColor = 'Green';
ComboBox<String>(
value: selectedColor,
items: colors.entries.map((e) {
return ComboboxItem(
child: Text(e.key),
value: e.key,
);
}).toList(),
onChanged: disabled ? null : (color) => setState(() => selectedColor = color),
Form(
autovalidateMode: AutovalidateMode.always,
child: ComboboxFormField<String>(
value: selectedColor,
items: colors.entries.map((e) {
return ComboboxItem(
child: Text(e.key),
value: e.key,
);
}).toList(),
onChanged: disabled ? null : (color) => setState(() => selectedColor = color),
validator: (text) {
if (text == null || text.isEmpty) {
return 'Please provide a value';
}
final acceptedValues = colors.keys.skip(4);
if (!acceptedValues.contains(text)) {
return '\$text is not a valid value today';
}
return null;
},
),
),''',
),
subtitle(content: const Text('Open popup programatically')),
Expand Down

0 comments on commit 9b1e8d4

Please sign in to comment.