show<T> static method

Future<T?> show<T>(
  1. BuildContext context, {
  2. required String message,
  3. String? key,
  4. Curve? curve,
  5. bool? onGoing,
  6. String? title,
  7. Duration? duration,
  8. Curve? reverseCurve,
  9. Duration? animeDuration,
  10. NoticeStyle? style,
  11. CustomOverlayToken<T>? token,
  12. List<Widget> actions = const [],
  13. NoticeStatus status = NoticeStatus.info,
})

Implementation

static Future<T?> show<T>(
  BuildContext context, {
  required String message,
  String? key,
  Curve? curve,
  bool? onGoing,
  String? title,
  Duration? duration,
  Curve? reverseCurve,
  Duration? animeDuration,
  NoticeStyle? style,
  CustomOverlayToken<T>? token,
  List<Widget> actions = const [],
  NoticeStatus status = NoticeStatus.info,
}) {
  token ??= CustomOverlayToken<T>();
  final themeData = NoticeThemeData.of(context);
  final noticeTimer = _NoticeTimer(
    autoStart: true,
    func: token.cancel,
    duration: duration ?? themeData.duration,
    isEffective: !(onGoing ?? themeData.onGoing),
  );
  return _customOverlay.insert<T>(
    context,
    key: key,
    token: token,
    dismissible: false,
    interceptPop: false,
    alignment: Alignment.topCenter,
    animationDuration: animeDuration ?? themeData.animeDuration,
    builder: (_, animation, _) {
      return SafeArea(
        child: Dismissible(
          direction: DismissDirection.up,
          onDismissed: (_) => token?.cancel(null, false),
          onUpdate: (details) =>
              noticeTimer.pauseOrResume(details.progress > 0),
          key: ValueKey(DateTime.now().microsecondsSinceEpoch),
          child: SlideTransition(
            position:
                Tween<Offset>(
                  begin: const Offset(0, -1),
                  end: const Offset(0, 0),
                ).animate(
                  CurvedAnimation(
                    parent: animation,
                    curve: curve ?? themeData.curve,
                    reverseCurve: reverseCurve ?? themeData.reverseCurve,
                  ),
                ),
            child: NoticeView(
              title: title,
              status: status,
              message: message,
              actions: actions,
              style: style ?? themeData.style,
            ),
          ),
        ),
      );
    },
  );
}