android static method

WeActionSheetAndroid android(
  1. BuildContext context
)

Implementation

static WeActionSheetAndroid android(BuildContext context) {
  return ({maskClosable = true, onClose, onChange, required options}) {
    final GlobalKey widgetKey = GlobalKey();
    late Function remove;

    // 关闭
    void hide() {
      remove();
      if (onClose is Function) {
        onClose!();
      }
    }

    // 点击
    void itemClick(int index) {
      remove();
      if (onChange is Function) {
        final String? value = options[index].value;
        onChange!(value == null ? index.toString() : value);
      }
    }

    remove = createOverlayEntry(
        context: context,
        backIntercept: true,
        child: AndroidWidget(
            key: widgetKey,
            maskClosable: maskClosable,
            close: hide,
            onChange: itemClick,
            children: options),
        willPopCallback: () {
          (widgetKey.currentState as AndroidWidgetState).close();
        });
  };
}