show method
FToasterEntry
show({
- required Widget builder(
- BuildContext context,
- FToasterEntry entry
- BuildContext? context,
- FToastStyle style(
- FToastStyle style
- 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,
FToastStyle Function(FToastStyle style)? style,
FToastAlignment? alignment,
List<AxisDirection>? swipeToDismiss,
Duration? duration = const Duration(seconds: 5),
VoidCallback? onDismiss,
}) {
context ??= this.context;
final direction = Directionality.maybeOf(context) ?? TextDirection.ltr;
final toasterStyle = widget.style?.call(context.theme.toasterStyle) ?? context.theme.toasterStyle;
final resolved = (alignment ?? toasterStyle.toastAlignment)._alignment.resolve(direction);
final directions = swipeToDismiss ?? [if (resolved.x < 1) AxisDirection.left else AxisDirection.right];
final entry = ToasterEntry(
style?.call(toasterStyle.toastStyle) ?? 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;
}