FormeSearchable<T extends Object>.dialog constructor

FormeSearchable<T extends Object>.dialog({
  1. required String name,
  2. required FormeQuery<T> query,
  3. WidgetBuilder? contentBuilder,
  4. Size? sizeProvider(
    1. BuildContext context
    )?,
  5. FormeDialogConfiguration? dialogConfiguration,
  6. bool multiSelect = true,
  7. FormeSearchableSelectedItemsBuilder<T>? selectedItemsBuilder,
  8. Key? key,
  9. List<T>? initialValue,
  10. bool registrable = true,
  11. bool enabled = true,
  12. bool readOnly = false,
  13. int? order,
  14. bool quietlyValidate = false,
  15. Duration? asyncValidatorDebounce,
  16. AutovalidateMode? autovalidateMode,
  17. FormeValueChanged<List<T>>? onValueChanged,
  18. FormeFocusChanged<List<T>>? onFocusChanged,
  19. FormeFieldSetter<List<T>>? onSaved,
  20. FormeValidator<List<T>>? validator,
  21. FormeAsyncValidator<List<T>>? asyncValidator,
  22. FormeFieldValidationChanged<List<T>>? onValidationChanged,
  23. FormeFieldInitialed<List<T>>? onInitialed,
  24. InputDecoration? decoration,
  25. int? limit,
  26. FormeSearchableOnLimitExceeded<T>? onLimitExceeded,
  27. FormeFieldDecorator<List<T>>? decorator,
  28. Widget selectableItemBuilder(
    1. BuildContext context,
    2. int index,
    3. T data,
    4. bool isSelected,
    )?,
  29. bool resizeToAvoidBottomInset = true,
  30. bool open = false,
})

Implementation

factory FormeSearchable.dialog({
  required String name,
  required FormeQuery<T> query,
  WidgetBuilder? contentBuilder,
  Size? Function(BuildContext context)? sizeProvider,
  FormeDialogConfiguration? dialogConfiguration,
  bool multiSelect = true,
  FormeSearchableSelectedItemsBuilder<T>? selectedItemsBuilder,
  Key? key,
  List<T>? initialValue,
  bool registrable = true,
  bool enabled = true,
  bool readOnly = false,
  int? order,
  bool quietlyValidate = false,
  Duration? asyncValidatorDebounce,
  AutovalidateMode? autovalidateMode,
  FormeValueChanged<List<T>>? onValueChanged,
  FormeFocusChanged<List<T>>? onFocusChanged,
  FormeFieldSetter<List<T>>? onSaved,
  FormeValidator<List<T>>? validator,
  FormeAsyncValidator<List<T>>? asyncValidator,
  FormeFieldValidationChanged<List<T>>? onValidationChanged,
  FormeFieldInitialed<List<T>>? onInitialed,
  InputDecoration? decoration,
  int? limit,
  FormeSearchableOnLimitExceeded<T>? onLimitExceeded,
  FormeFieldDecorator<List<T>>? decorator,
  Widget Function(BuildContext context, int index, T data, bool isSelected)?
      selectableItemBuilder,
  bool resizeToAvoidBottomInset = true,
  bool open = false,
}) {
  return FormeSearchable._(
    open: open,
    proxyBuilder: (context, link, contentBuilder) {
      final bool useRootNavigator =
          dialogConfiguration?.useRootNavigator ?? true;
      showDialog<void>(
        barrierDismissible: dialogConfiguration?.barrierDismissible ?? false,
        barrierColor: dialogConfiguration?.barrierColor ?? Colors.black54,
        barrierLabel: dialogConfiguration?.barrierLabel,
        useSafeArea: dialogConfiguration?.useSafeArea ?? true,
        useRootNavigator: useRootNavigator,
        context: context,
        builder: (context) {
          return contentBuilder(context);
        },
      );
      final NavigatorState navigator =
          Navigator.of(context, rootNavigator: useRootNavigator);
      Route? last;
      navigator.popUntil((route) {
        last = route;
        return true;
      });
      return FormeSearchableRouteProxyController(
        last!,
        navigator,
      );
    },
    query: query,
    decorator: decorator,
    limit: limit,
    onLimitExceeded: onLimitExceeded,
    decoration: decoration,
    enabled: enabled,
    onInitialed: onInitialed,
    registrable: registrable,
    order: order,
    quietlyValidate: quietlyValidate,
    asyncValidatorDebounce: asyncValidatorDebounce,
    autovalidateMode: autovalidateMode,
    onValueChanged: onValueChanged,
    onFocusChanged: onFocusChanged,
    onValidationChanged: onValidationChanged,
    onSaved: onSaved,
    validator: validator,
    asyncValidator: asyncValidator,
    key: key,
    readOnly: readOnly,
    name: name,
    initialValue: initialValue,
    selectedItemsBuilder: selectedItemsBuilder,
    multiSelect: multiSelect,
    contentBuilder: contentBuilder ??
        (context) {
          return FormeSearchableDefaultContent<T>(
            selectableItemBuilder: selectableItemBuilder,
          );
        },
    contentDecorator: (context, content) {
      Widget child;

      final MediaQueryData mediaQuery = MediaQuery.of(context);
      final Size size = sizeProvider?.call(context) ?? mediaQuery.size;
      if (resizeToAvoidBottomInset) {
        double bottomPadding;
        if (size == mediaQuery.size) {
          bottomPadding = mediaQuery.viewInsets.bottom;
        } else {
          double statusBarHeight = 0;
          if (dialogConfiguration?.useSafeArea ?? true) {
            statusBarHeight = mediaQuery.padding.top;
          }
          final double bottom = (mediaQuery.size.height - size.height) / 2;
          bottomPadding =
              mediaQuery.viewInsets.bottom - bottom + statusBarHeight / 2;
          if (bottomPadding < 0) {
            bottomPadding = 0;
          }
        }
        child = Padding(
          padding: EdgeInsets.only(bottom: bottomPadding),
          child: content,
        );
      } else {
        child = content;
      }

      return Center(
        child: SizedBox(
          height: size.height,
          width: size.width,
          child: child,
        ),
      );
    },
  );
}