Custom topic

Custom

Custom manager setup

If you want to use your own handmade Manager, you can define a class that extends EasyDialogManager and optionally specify your hide/show parameters. Pay attention to the usage of BasicDialogInsertStrategy/BasicDialogRemoveStrategy strategy. The insertion strategy callback passes an ID of the inserted dialog entry within EasyDialogsOverlay, which later can be used to remove that dialog. Lastly, it is necessary to register your Manager before it is used:


class MyDialogManager extends EasyDialogManager<EasyDialogManagerShowParams,
    EasyDialogManagerHideParams> with SingleAutoDisposalControllerMixin {
  MyDialogManager({required super.overlayController});

  int? _id;

  @override
  Future<void> hide({required EasyDialogManagerHideParams params}) => _hide();

  Future<void> _hide() =>
      hideAndDispose(BasicDialogRemoveStrategy(dialogId: _id!));

  @override
  Future<void> show({required EasyDialogManagerShowParams params}) async {
    if (isPresented) await _hide();

    await initializeAndShow(params, (animation) {
      var dialog = params.content;

      dialog = const CustomAnimator()
          .decorate(EasyDialogAnimatorData(parent: animation, dialog: dialog));

      dialog = const CustomDismissible().decorate(
        EasyDismissibleData(
          dialog: dialog,
          dismissHandler: (_) => _hide(),
        ),
      );

      return BasicDialogInsertStrategy(
        dialog: dialog,
        onInserted: (dialogId) => _id = dialogId,
      );
    });
  }

  @override
  AnimationController createAnimationController(
    TickerProvider vsync,
    EasyDialogManagerShowParams params,
  ) =>
      params.animationConfiguration.createController(vsync);
}

class CustomAnimator extends EasyDialogAnimator {
  const CustomAnimator();

  @override
  Widget decorate(EasyDialogAnimatorData data) {
    return FadeTransition(
      opacity: data.parent,
      child: data.dialog,
    );
  }
}

class CustomDismissible extends EasyDialogDismissible {
  const CustomDismissible();

  @override
  Widget decorate(EasyDismissibleData<EasyDismissiblePayload> data) {
    return GestureDetector(
      behavior: HitTestBehavior.deferToChild,
      onTap: () {
        data.dismissHandler?.call(const EasyDismissiblePayload());
        super.onDismissed?.call();
      },
      child: data.dialog,
    );
  }
}


Custom manager usage

Simply call with your Manager type provided as a generic:

FlutterEasyDialogs.provider.use<MyDialogManager>().show(
      params: EasyDialogManagerShowParams(
        content: Container(
          alignment: Alignment.center,
          color: Colors.amber.withOpacity(0.6),
          padding: const EdgeInsets.all(30.0),
          child: const Text(
            'My custom manager',
            style: TextStyle(
              fontSize: 30.0,
              color: Colors.white,
            ),
          ),
        ),
      ),
    );

Custom manager example

custom-manager

Classes

BasicDialogInsertStrategy Getting started Dialog manager Custom
Simple insert dialog strategy.
BasicDialogInsertStrategy Getting started Dialog manager Custom
Simple insert dialog strategy.
BasicDialogRemoveStrategy Getting started Dialog manager Custom
Simple implementation of remove strategy.
BasicDialogRemoveStrategy Getting started Dialog manager Custom
Simple implementation of remove strategy.
EasyDialogAnimator<D extends EasyDialogAnimatorData> Decorators Custom
Base class of animator for dialogs.
EasyDialogAnimator<D extends EasyDialogAnimatorData> Decorators Custom
Base class of animator for dialogs.
EasyDialogAnimatorData Decorators Custom
This is specific to the EasyDialogAnimator data and requires a mandatory parent of type Animation.
EasyDialogAnimatorData Decorators Custom
This is specific to the EasyDialogAnimator data and requires a mandatory parent of type Animation.
EasyDialogDecorator<D extends EasyDialogDecoratorData?> Decorators Custom
This class is intended to be used within the by EasyDialogManager.
EasyDialogDecorator<D extends EasyDialogDecoratorData?> Decorators Custom
This class is intended to be used within the by EasyDialogManager.
EasyDialogDecoratorData Decorators Custom
Core data class which is used within EasyDialogDecorator.decorate.
EasyDialogDecoratorData Decorators Custom
Core data class which is used within EasyDialogDecorator.decorate.
EasyDialogDismissible<D extends EasyDismissibleData<P>, P extends EasyDismissiblePayload> Decorators Custom
The main purpose is to make provided EasyDismissibleData.dialog dismissible.
EasyDialogDismissible<D extends EasyDismissibleData<P>, P extends EasyDismissiblePayload> Decorators Custom
The main purpose is to make provided EasyDismissibleData.dialog dismissible.
EasyDialogManager<S extends EasyDialogManagerShowParams?, H extends EasyDialogManagerHideParams?> Getting started Dialog manager Custom
This is the base class for all dialog managers.
EasyDialogManager<S extends EasyDialogManagerShowParams?, H extends EasyDialogManagerHideParams?> Getting started Dialog manager Custom
This is the base class for all dialog managers.
EasyDialogManagerHideParams Getting started Dialog manager Custom
Base class of hide params for dialog managers.
EasyDialogManagerHideParams Getting started Dialog manager Custom
Base class of hide params for dialog managers.
EasyDialogManagerShowParams Getting started Dialog manager Custom
Base data class of show params for dialog managers.
EasyDialogManagerShowParams Getting started Dialog manager Custom
Base data class of show params for dialog managers.
EasyDismissibleData<P extends EasyDismissiblePayload> Decorators Custom
This is specific to the EasyDialogDismissible data.
EasyDismissibleData<P extends EasyDismissiblePayload> Decorators Custom
This is specific to the EasyDialogDismissible data.
EasyDismissiblePayload Decorators Custom
Sometimes it is necessary to provide some payload to EasyDialogManager, which is responsible for dismissing the dialog.
EasyDismissiblePayload Decorators Custom
Sometimes it is necessary to provide some payload to EasyDialogManager, which is responsible for dismissing the dialog.
EasyOverlayBoxInsert<M extends EasyDialogManager<EasyDialogManagerShowParams?, EasyDialogManagerHideParams?>> Overlay Custom
Insert mutation.
EasyOverlayBoxInsert<M extends EasyDialogManager<EasyDialogManagerShowParams?, EasyDialogManagerHideParams?>> Overlay Custom
Insert mutation.
EasyOverlayBoxMutation<M extends EasyDialogManager<EasyDialogManagerShowParams?, EasyDialogManagerHideParams?>, R extends EasyOverlayEntry?> Overlay Custom
Similar to Command/Strategy class for applying specific mutation within IEasyDialogsOverlayBox.
EasyOverlayBoxMutation<M extends EasyDialogManager<EasyDialogManagerShowParams?, EasyDialogManagerHideParams?>, R extends EasyOverlayEntry?> Overlay Custom
Similar to Command/Strategy class for applying specific mutation within IEasyDialogsOverlayBox.
EasyOverlayBoxRemove<M extends EasyDialogManager<EasyDialogManagerShowParams?, EasyDialogManagerHideParams?>> Overlay Custom
Remove mutation.
EasyOverlayBoxRemove<M extends EasyDialogManager<EasyDialogManagerShowParams?, EasyDialogManagerHideParams?>> Overlay Custom
Remove mutation.
IEasyDialogsOverlayBox Overlay Custom
Box for storing dialog specific entries.
IEasyDialogsOverlayBox Overlay Custom
Box for storing dialog specific entries.
IEasyOverlayController Overlay Custom
Controller for manipulating overlay with the dialogs.
IEasyOverlayController Overlay Custom
Controller for manipulating overlay with the dialogs.

Typedefs

DismissHandler<P extends EasyDismissiblePayload> = FutureOr<void> Function(P payload) Decorators Custom
Callback to handle dismiss on a EasyDialogManager side.
DismissHandler<P extends EasyDismissiblePayload> = FutureOr<void> Function(P payload) Decorators Custom
Callback to handle dismiss on a EasyDialogManager side.
EasyDialogDecoratorDataBuilder<D extends EasyDialogDecoratorData?> = D Function(Widget newChild, D previousData) Decorators Custom
typedef alias that is used in EasyDialogDecorator.combine.
EasyDialogDecoratorDataBuilder<D extends EasyDialogDecoratorData?> = D Function(Widget newChild, D previousData) Decorators Custom
typedef alias that is used in EasyDialogDecorator.combine.
OnEasyDismissed = void Function() Decorators Custom
Dismiss callback.
OnEasyDismissed = void Function() Decorators Custom
Dismiss callback.