show static method
FutureOr<void>
show({
- required Widget child,
- required BuildContext context,
- double? top,
- double? left,
- double? right,
- VoidCallback? onTap,
- Duration duration = const Duration(seconds: 10),
- Curve curve = Curves.easeOutCubic,
- Curve dismissCurve = Curves.easeOutCubic,
- @visibleForTesting FutureOr notificationCreatedCallback()?,
Shows specified Widget as notification.
child
is required, this will be displayed as notification body.
context
is required, this is used to get internally used notification controller class which is subclass of InheritedWidget
.
Showing and hiding notifications is managed by animation, and the process is as follows.
- Execute this method, start animation via call state's
show
method internally. - Then the notification appear, it will stay at specified
duration
. - After the
duration
has elapsed, play the animation in reverse and dispose the notification.
This method will awaits an animation that showing the notification.
Implementation
static FutureOr<void> show({
required Widget child,
required BuildContext context,
double? top,
double? left,
double? right,
VoidCallback? onTap,
Duration duration = const Duration(seconds: 10),
Curve curve = Curves.easeOutCubic,
Curve dismissCurve = Curves.easeOutCubic,
bool useRootNavigator = false,
// ignore: strict_raw_type
@visibleForTesting FutureOr Function()? notificationCreatedCallback,
}) async {
final controller = _NotificationController.of(context);
assert(controller != null, 'Not found InAppNotification controller.');
await controller!.create(
child: child,
context: context,
onTap: onTap,
top: top ?? 0.0,
left: left,
right: right,
useRootNavigator: useRootNavigator,
);
if (kDebugMode) {
await notificationCreatedCallback?.call();
}
await controller.show(
duration: duration,
curve: curve,
dismissCurve: dismissCurve,
top: top ?? 0.0,
);
}