show<T> static method
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,
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,
),
),
),
);
},
);
}