Decorators topic
Decorators
This is a special abstraction that is commonly used by Managers to decorate the behavior or appearance of the content provided to be presented within the dialog
.
It's very simple to use:
abstract class EasyDialogDecorator<D extends EasyDialogDecoratorData?> {
const EasyDialogDecorator();
Widget decorate(D data);
}
You just need to implement the decorate method and provide your EasyDialogDecoratorData to it. The only mandatory property is dialog
. As you may notice, you can extend this data class and specify a generic
parameter within the EasyDialogDecorator bounds to be able to pass any kind of data as per your needs.
class EasyDialogDecoratorData {
final Widget dialog;
const EasyDialogDecoratorData({required this.dialog});
}
Animators
This is the way to animate the dialogs:
abstract class EasyDialogAnimator<D extends EasyDialogAnimatorData>
extends EasyDialogDecorator<D> {
/// Desired curve to be applied to the animation.
final Curve curve;
const EasyDialogAnimator({this.curve = Curves.linear});
}
It is used within the Manager logic of showing the dialogs with specific data:
class EasyDialogAnimatorData extends EasyDialogDecoratorData {
final Animation<double> parent;
const EasyDialogAnimatorData({required this.parent, required super.dialog});
}
The stumbling block is parent
argument. Simply put, it is AnimationController that was created by a specific Manager and provided to Animator, so it could apply some transitions or any other change-based value to the dialog
.
Dismissible
Generally, it is the way to dismiss dialogs with provided VoidCallback. It's responsibility is to provide specific dismissible behavior to the dialog and to handle the dismissing:
typedef OnEasyDismissed = void Function();
typedef DismissHandler<P extends EasyDismissiblePayload> = FutureOr<void>
Function(P payload);
abstract class EasyDialogDismissible<D extends EasyDismissibleData<P>,
P extends EasyDismissiblePayload> extends EasyDialogDecorator<D> {
final OnEasyDismissed? onDismissed;
const EasyDialogDismissible({this.onDismissed});
}
There are several data classes:
- EasyDismissibleData, that provides the dismissHandler function which is optional. Sometimes it is necessary to perform certain actions when the actual onDismissed callback is called:
class EasyDismissibleData<P extends EasyDismissiblePayload>
extends EasyDialogDecoratorData {
final DismissHandler<P>? dismissHandler;
const EasyDismissibleData({required super.dialog, this.dismissHandler});
}
The desired payload that the dismissible may pass back to the Manager on handle, as always, this class may be extended and specified in the generic parameter of an EasyDialogDismissible:
class EasyDismissiblePayload {
final bool instantDismiss;
const EasyDismissiblePayload({this.instantDismiss = false});
}
Similar to the Animators, the Dismissible is provided to the Manager, and the Manager is responsible for providing the specified dismissible behavior to the dialog
.
Shells
This is the wrapper Widget that provides some sort of shape to the content of the dialog. It is not mandatory, but it could be very handy to apply some additional components around the provided content
.
Classes
-
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< Decorators CustomP> , P extends EasyDismissiblePayload> - The main purpose is to make provided EasyDismissibleData.dialog dismissible.
-
EasyDialogDismissible<
D extends EasyDismissibleData< Decorators CustomP> , P extends EasyDismissiblePayload> - The main purpose is to make provided EasyDismissibleData.dialog dismissible.
-
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.
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.