MySelector class
通用选择器浮层
在 triggerContext 所指 Widget 附近弹出一个面板,面板内含可选搜索框、
富格式列表和可选底部区域。
返回 MySelectorResult:
- MySelectorDismissed:用户点击外部或按 Escape,不做任何操作
- MySelectorValueChanged:用户做出了明确操作;
value == null表示主动清除,value != null表示选中了某项
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< items, T? currentValue, MySelectorClearOption? clearOption, bool allowReselect = false, bool? showPanelAbove, bool showSearch = false, String searchHint = '搜索…', bool searchFilter(MySelectorItem<T> >T> item, String query)?, Widget itemBuilder(BuildContext context, MySelectorItem<T> item, bool isSelected)?, MySelectorStyle? style}) → Future<MySelectorResult< T> > - 弹出选择器面板,返回 MySelectorResult 告知调用方用户的操作意图。