MySelector class

通用选择器浮层

triggerContext 所指 Widget 附近弹出一个面板,面板内含可选搜索框、 富格式列表和可选底部区域。

返回 MySelectorResult

final result = await MySelector.show<String>(
  triggerContext: context,
  items: [...],
  currentValue: selected,
  showSearch: true,
  clearOption: MySelectorClearOption(label: '不选择'),
  allowReselect: true,
);
switch (result) {
  case MySelectorDismissed(): break;
  case MySelectorValueChanged(:final value):
    state = value; // null = cleared, non-null = selected
}

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

show<T>({required BuildContext triggerContext, required List<MySelectorItem<T>> items, T? currentValue, MySelectorClearOption? clearOption, bool allowReselect = false, bool? showPanelAbove, bool showSearch = false, String searchHint = '搜索…', bool searchFilter(MySelectorItem<T> item, String query)?, Widget itemBuilder(BuildContext context, MySelectorItem<T> item, bool isSelected)?, Widget footerBuilder(BuildContext context, VoidCallback dismiss)?, MySelectorStyle? style}) Future<MySelectorResult<T>>
弹出选择器面板,返回 MySelectorResult 告知调用方用户的操作意图。