SelectionMenuForm<T> constructor
SelectionMenuForm<T> ({
- required WidgetBuilder selectorBuilder,
- required DropDownButtonBuilder? buttonBuilder,
- SelectionMenuFormController? controller,
- LayoutSelectPop? layoutSelectPop,
- DropDownPopCreated? onCreated,
- DropDownPopShow? onShow,
- DropDownPopDismiss? onDismiss,
- bool enableOnHover = false,
- bool enableClick = true,
- bool matchParentWidth = true,
- double popWidth = 0,
- double hMargin = 0,
- double vMargin = 0,
- double popHeight = 200,
- BorderRadiusGeometry? materialBorderRadius,
- Color? color = Colors.transparent,
- ShapeBorder? shape,
- double elevation = 0.0,
- Color? shadowColor,
- String? barrierLabel,
- Color? barrierColor,
- bool barrierDismissible = true,
- Duration transitionDuration = const Duration(milliseconds: 200),
- AlignType alignType = AlignType.left,
- GestureTapCallback? onDoubleTap,
- GestureLongPressCallback? onLongPress,
- GestureTapDownCallback? onTapDown,
- GestureTapUpCallback? onTapUp,
- GestureTapCancelCallback? onTapCancel,
- ValueChanged<
bool> ? onHighlightChanged, - ValueChanged<
bool> ? onHover, - MouseCursor? mouseCursor,
- Color? focusColor,
- Color? hoverColor,
- Color? highlightColor,
- WidgetStateProperty<
Color?> ? overlayColor, - Color? splashColor,
- InteractiveInkFeatureFactory? splashFactory,
- double? radius,
- BorderRadius? borderRadius,
- ShapeBorder? customBorder,
- bool enableFeedback = true,
- bool excludeFromSemantics = false,
- FocusNode? focusNode,
- bool canRequestFocus = true,
- ValueChanged<
bool> ? onFocusChange, - bool autofocus = false,
- AutovalidateMode? autovalidateMode,
- ScrollController? scrollController,
- String? restorationId,
- FormFieldSetter? onSaved,
- FormFieldValidator? validator,
- bool? enabled,
- required ValueNotifier<
FormTips> valueNotifier, - Widget? noneTips,
- Widget? warningTips,
- Widget? errorTips,
- InputDecoration decoration = const InputDecoration(),
- Key? key,
Implementation
SelectionMenuForm(
{required this.selectorBuilder,
required this.buttonBuilder,
this.controller,
this.layoutSelectPop,
this.onCreated,
this.onShow,
this.onDismiss,
this.enableOnHover = false,
this.enableClick = true,
this.matchParentWidth = true,
this.popWidth = 0,
this.hMargin = 0,
this.vMargin = 0,
this.popHeight = 200,
this.materialBorderRadius,
this.color = Colors.transparent,
this.shape,
this.elevation = 0.0,
this.shadowColor,
this.barrierLabel,
this.barrierColor,
this.barrierDismissible = true,
this.transitionDuration = const Duration(milliseconds: 200),
this.alignType = AlignType.left,
this.onDoubleTap,
this.onLongPress,
this.onTapDown,
this.onTapUp,
this.onTapCancel,
this.onHighlightChanged,
this.onHover,
this.mouseCursor,
this.focusColor,
this.hoverColor,
this.highlightColor,
this.overlayColor,
this.splashColor,
this.splashFactory,
this.radius,
this.borderRadius,
this.customBorder,
this.enableFeedback = true,
this.excludeFromSemantics = false,
this.focusNode,
this.canRequestFocus = true,
this.onFocusChange,
this.autofocus = false,
AutovalidateMode? autovalidateMode,
ScrollController? scrollController,
String? restorationId,
FormFieldSetter? onSaved,
FormFieldValidator? validator,
bool? enabled,
required ValueNotifier<FormTips> valueNotifier,
Widget? noneTips,
Widget? warningTips,
Widget? errorTips,
InputDecoration decoration = const InputDecoration(),
Key? key})
: super(
key: key,
restorationId: restorationId,
onSaved: onSaved,
validator: validator,
autovalidateMode: autovalidateMode ?? AutovalidateMode.disabled,
builder: (FormFieldState field) {
final SelectionMenuFormState state =
field as SelectionMenuFormState;
return UnmanagedRestorationScope(
bucket: field.bucket,
child: Builder(builder: (context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
key: state._rootKey,
onDoubleTap: onDoubleTap,
onLongPress: onLongPress,
onTapDown: onTapDown,
onTapUp: onTapUp,
onTapCancel: onTapCancel,
onHighlightChanged: onHighlightChanged,
mouseCursor: mouseCursor,
focusColor: focusColor,
hoverColor: hoverColor,
highlightColor: highlightColor,
overlayColor: overlayColor,
splashColor: splashColor,
splashFactory: splashFactory,
radius: radius,
borderRadius: borderRadius,
customBorder: customBorder,
enableFeedback: enableFeedback,
excludeFromSemantics: excludeFromSemantics,
focusNode: focusNode,
canRequestFocus: canRequestFocus,
onFocusChange: onFocusChange,
autofocus: autofocus,
onHover: (hover) {
if (hover && enableOnHover) {
state._showSelection(context);
return;
}
},
onTap: () {
if(enabled == false) {
return;
}
if (!enableClick) {
return;
}
if (state._popShowIng) {
return;
}
state._showSelection(context);
},
child: buttonBuilder?.call(state._popShowIng),
),
ValueListenableBuilder<FormTips>(
valueListenable: valueNotifier,
builder: (context, value, child) {
if (value == FormTips.warning) {
return warningTips ?? const SizedBox();
}
if (value == FormTips.error) {
return errorTips ?? const SizedBox();
}
return const SizedBox();
})
],
);
}),
);
},
);