showRawFToast function

FToasterEntry showRawFToast({
  1. required BuildContext context,
  2. required Widget builder(
    1. BuildContext context,
    2. FToasterEntry entry
    ),
  3. FToastStyle style(
    1. FToastStyle
    )?,
  4. FToastAlignment? alignment,
  5. List<AxisDirection>? swipeToDismiss,
  6. Duration? duration = const Duration(seconds: 5),
  7. VoidCallback? onDismiss,
})

Displays a raw toast in a toaster.

alignment defaults to FToasterStyle.toastAlignment.

swipeToDismiss represents axes in which to swipe to dismiss a toast. Defaults to horizontally towards the closest edge of the screen with a left bias. For example, if alignment is FToastAlignment.bottomRight, the default swipe direction is AxisDirection.right.

Set swipeToDismiss to an empty list to disable swiping to dismiss.

duration controls the duration which the toast is shown. Defaults to 5 seconds. Set duration to null to disable auto-closing.

Contract

Throws FlutterError if there is no ancestor FToaster in the given context.

See:

Implementation

FToasterEntry showRawFToast({
  required BuildContext context,
  required Widget Function(BuildContext context, FToasterEntry entry) builder,
  FToastStyle Function(FToastStyle)? style,
  FToastAlignment? alignment,
  List<AxisDirection>? swipeToDismiss,
  Duration? duration = const Duration(seconds: 5),
  VoidCallback? onDismiss,
}) {
  final state = context.findAncestorStateOfType<FToasterState>();
  if (state == null) {
    throw FlutterError.fromParts([
      ErrorSummary('showRawFToast(...) called with a context that does not contain a FToaster/FScaffold.'),
      ErrorDescription(
        'No FToaster/FScaffold ancestor could be found starting from the context that was passed to FToaster/FScaffold.of(). '
        'This usually happens when the context provided is from the same StatefulWidget as that whose build function '
        'actually creates the FToaster/FScaffold widget being sought.',
      ),
      ErrorHint(
        'There are several ways to avoid this problem. The simplest is to use a Builder to get a '
        'context that is "under" the FToaster/FScaffold.',
      ),
      context.describeElement('The context used was'),
    ]);
  }

  return state.show(
    context: context,
    builder: builder,
    style: style,
    alignment: alignment,
    swipeToDismiss: swipeToDismiss,
    duration: duration,
    onDismiss: onDismiss,
  );
}