string static method
EJSelectorButton<String>
string({
- Key? key,
- required List<
String> items, - String? value,
- bool useValue = true,
- String? hint,
- double dialogWidth = 80,
- double? buttonWidth,
- double? buttonHeight,
- double itemExtent = 50,
- void onChange()?,
- VoidCallback? onTap,
- Widget? divider,
- bool underline = true,
- TextStyle? textStyle,
- TextStyle? dialogTextStyle,
- TextStyle? hintStyle,
- Widget? suffix,
- Widget? prefix,
- TextOverflow? buttonTextOverFlow,
- Color underlineColor = Colors.grey,
- BoxDecoration? decoration,
- Alignment alignment = Alignment.center,
- EdgeInsets padding = const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
- EdgeInsets margin = EdgeInsets.zero,
- bool alwaysShownScrollbar = false,
- bool disable = false,
- VoidCallback? onDisableTap,
Implementation
static EJSelectorButton<String> string({
Key? key,
required List<String> items,
String? value,
bool useValue = true,
String? hint,
double dialogWidth = 80,
double? buttonWidth,
double? buttonHeight,
double itemExtent = 50,
void Function(String)? onChange,
VoidCallback? onTap,
Widget? divider,
bool underline = true,
TextStyle? textStyle,
TextStyle? dialogTextStyle,
TextStyle? hintStyle,
Widget? suffix,
Widget? prefix,
TextOverflow? buttonTextOverFlow,
Color underlineColor = Colors.grey,
BoxDecoration? decoration,
Alignment alignment = Alignment.center,
EdgeInsets padding = const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
EdgeInsets margin = EdgeInsets.zero,
bool alwaysShownScrollbar = false,
bool disable = false,
VoidCallback? onDisableTap,
}) {
return EJSelectorButton<String>(
hint: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (prefix != null) prefix,
Container(
alignment: alignment,
child: Text(hint ?? '', style: hintStyle ?? textStyle),
).addExpanded(buttonWidth != null),
if (suffix != null) suffix,
],
),
items: List.generate(items.length, (index) {
final item = items[index];
return EJSelectorItem<String>(
value: item,
widget: Builder(
builder: (context) => Container(
height: itemExtent,
alignment: Alignment.center,
child: Text(
item,
style: dialogTextStyle ??
textStyle ??
Theme.of(context).textTheme.bodyMedium,
),
),
));
}),
disable: disable,
onDisableTap: onDisableTap,
alwaysShowScrollBar: alwaysShownScrollbar,
useValue: useValue,
value: value,
selectedWidgetBuilder: (value) => Builder(
builder: (context) => Container(
height: itemExtent,
alignment: Alignment.center,
child: Text(
value,
style: Theme.of(context).textTheme.headlineSmall!.copyWith(
color: Theme.of(context).colorScheme.secondary,
fontWeight: FontWeight.bold),
),
),
),
divider: divider,
buttonBuilder: (child, value) => Builder(
builder: (context) => Container(
height: buttonHeight,
width: buttonWidth,
padding: padding,
margin: margin,
alignment: alignment,
decoration: decoration ??
BoxDecoration(
border: underline
? Border(
bottom: BorderSide(color: underlineColor, width: 2))
: Border(),
),
child: value != null
? Row(
mainAxisSize: MainAxisSize.min,
children: [
if (prefix != null) prefix,
Container(
alignment: alignment,
child: Text(
value,
overflow: buttonTextOverFlow,
style:
textStyle ?? Theme.of(context).textTheme.bodyMedium,
),
).addExpanded(buttonWidth != null),
if (suffix != null) suffix,
],
)
: child,
),
),
onChange: onChange,
onTap: onTap,
dialogWidth: dialogWidth,
dialogHeight: items.length * itemExtent,
key: key,
);
}