buildItem method
Builds the widget for a specific item in the current column.
This method is called for each visible item in the picker to create the widget that represents that item.
Parameters:
context
- The build contextindex
- The item index within the current column
Returns a widget representing the item.
Implementation
@override
Widget buildItem(BuildContext context, int index) {
final PickerItem item = _datas![index];
final isSel = index == picker!.selecteds[_col];
final theme = Theme.of(context);
if (picker!.onBuilderItem != null) {
final v = picker!.onBuilderItem!(
context, item.value.toString(), item.text, isSel, _col, index);
if (v != null) return makeText(v, null, isSel);
}
if (item.text != null) {
return isSel && picker!.selectedTextStyle != null
? Center(
child: DefaultTextStyle(
style: picker!.selectedTextStyle!,
textAlign: picker!.textAlign,
child: picker!.selectedIconTheme != null
? IconTheme(
data: picker!.selectedIconTheme!,
child: item.text!,
)
: item.text!),
)
: Center(
child: DefaultTextStyle(
style: picker!.textStyle ??
TextStyle(
color: theme.brightness == Brightness.dark
? material.Colors.white
: material.Colors.black87,
fontFamily: theme.textTheme.titleLarge?.fontFamily,
fontSize: Picker.defaultTextSize,
),
textAlign: picker!.textAlign,
child: picker!.selectedIconTheme != null
? IconTheme(
data: picker!.selectedIconTheme!,
child: item.text!,
)
: item.text!,
),
);
}
return makeText(
item.text, item.text != null ? null : item.value.toString(), isSel);
}