style property
The text style to use for text in the combobox button and the combobox menu that appears when you tap the button.
To use a separate text style for selected item when it's displayed within the combobox button, consider using selectedItemBuilder.
{@tool dartpad --template=stateful_widget_scaffold}
This sample shows a Combobox
with a combobox button text style
that is different than its menu items.
List<String> options = <String>['One', 'Two', 'Free', 'Four'];
String comboboxValue = 'One';
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
color: Colors.blue,
child: Combobox<String>(
value: comboboxValue,
onChanged: (String? newValue) {
setState(() {
comboboxValue = newValue!;
});
},
style: TextStyle(color: Colors.blue),
selectedItemBuilder: (BuildContext context) {
return options.map((String value) {
return Text(
comboboxValue,
style: TextStyle(color: Colors.white),
);
}).toList();
},
items: options.map<ComboboxItem<String>>((String value) {
return ComboboxItem<String>(
value: value,
child: Text(value),
);
}).toList(),
),
);
}
{@end-tool}
Defaults to the TextTheme.subtitle1
value of the current
ThemeData.textTheme
of the current Theme.
Implementation
final TextStyle? style;