build method
Build the picker.
context
is passed BuildContext. currentKey
is passed the currently selected key.
ピッカーのビルドを行ないます。
context
にBuildContextが渡されます。currentKey
に現在選択されているキーが渡されます。
Implementation
Future<String?> build(BuildContext context, String? currentKey) async {
String? res;
final keys = data.keys.toList();
final theme = Theme.of(context);
await _Picker(
height: 240,
backgroundColor: backgroundColor ?? theme.colorScheme.surface,
containerColor: backgroundColor ?? theme.colorScheme.surface,
headerColor: backgroundColor ?? theme.colorScheme.surface,
textStyle: TextStyle(color: color ?? theme.colorScheme.onSurface),
confirmText: confirmText,
cancelText: cancelText,
selecteds: [
keys.indexOf(currentKey ?? defaultKey),
],
adapter: _PickerDataAdapter<String>(
data: [
...keys.map((key) {
return _PickerItem<String>(
text: Text(
data[key] ?? "",
style: TextStyle(
color: color ?? theme.colorScheme.onSurface,
),
),
value: key,
);
})
],
),
changeToFirst: true,
hideHeader: false,
onConfirm: (_Picker picker, List<int> value) {
res = keys[value[0]];
},
).showModal(context);
return res;
}