show static method

FutureOr<void> show({
  1. required Widget child,
  2. required BuildContext context,
  3. VoidCallback? onTap,
  4. Duration duration = const Duration(seconds: 10),
  5. Curve curve = Curves.easeOutCubic,
  6. Curve dismissCurve = Curves.easeOutCubic,
  7. @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.

  1. Execute this method, start animation via call state's show method internally.
  2. Then the notification appear, it will stay at specified duration.
  3. 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,
  VoidCallback? onTap,
  Duration duration = const Duration(seconds: 10),
  Curve curve = Curves.easeOutCubic,
  Curve dismissCurve = Curves.easeOutCubic,
  @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);
  if (kDebugMode) {
    await notificationCreatedCallback?.call();
  }
  controller.show(
      duration: duration, curve: curve, dismissCurve: dismissCurve);
}