string static method

EJSelectorButton<String> string({
  1. Key? key,
  2. required List<String> items,
  3. String? value,
  4. bool useValue = true,
  5. String? hint,
  6. double dialogWidth = 80,
  7. double? buttonWidth,
  8. double? buttonHeight,
  9. double itemExtent = 50,
  10. void onChange(
    1. String
    )?,
  11. VoidCallback? onTap,
  12. Widget? divider,
  13. bool underline = true,
  14. TextStyle? textStyle,
  15. TextStyle? dialogTextStyle,
  16. TextStyle? hintStyle,
  17. Widget? suffix,
  18. Widget? prefix,
  19. TextOverflow? buttonTextOverFlow,
  20. Color underlineColor = Colors.grey,
  21. BoxDecoration? decoration,
  22. Alignment alignment = Alignment.center,
  23. EdgeInsets padding = const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
  24. EdgeInsets margin = EdgeInsets.zero,
  25. bool alwaysShownScrollbar = false,
  26. bool disable = false,
  27. 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,
  );
}