show method
FToasterEntry
show({
- required Widget builder(
- BuildContext context,
- FToasterEntry entry
- BuildContext? context,
- FToastStyleDelta style = const .context(),
- FToastAlignment? alignment,
- List<
AxisDirection> ? swipeToDismiss, - Duration? duration = const Duration(seconds: 5),
- VoidCallback? onDismiss,
Displays a toast in this toaster.
It is generally recommend to use showFToast or showRawFToast instead.
See showRawFToast for more information about the parameters.
Implementation
FToasterEntry show({
required Widget Function(BuildContext context, FToasterEntry entry) builder,
BuildContext? context,
FToastStyleDelta style = const .context(),
FToastAlignment? alignment,
List<AxisDirection>? swipeToDismiss,
Duration? duration = const Duration(seconds: 5),
VoidCallback? onDismiss,
}) {
context ??= this.context;
final direction = Directionality.maybeOf(context) ?? .ltr;
final toasterStyle = widget.style(context.theme.toasterStyle);
final resolved = (alignment ?? toasterStyle.toastAlignment)._alignment.resolve(direction);
final directions = swipeToDismiss ?? [if (resolved.x < 1) .left else .right];
final entry = ToasterEntry(style(toasterStyle.toastStyle), resolved, directions, duration, builder);
entry.onDismiss = () {
entry.dismissing.value = true;
_remove(entry);
onDismiss?.call();
};
if (!mounted) {
return entry;
}
setState(() {
final (_, entries) = _entries[resolved] ??= ((alignment ?? toasterStyle.toastAlignment)._toastAlignment, []);
entries.add(entry);
});
return entry;
}