copyWith method

  1. @useResult
FToastStyle copyWith({
  1. Duration? enterExitDuration,
  2. Curve? enterCurve,
  3. Curve? exitCurve,
  4. double? entranceExitOpacity,
  5. Duration? transitionDuration,
  6. Curve? transitionCurve,
  7. Duration? swipeCompletionDuration,
  8. Curve? swipeCompletionCurve,
  9. BoxConstraints? constraints,
  10. BoxDecoration? decoration,
  11. ImageFilter? backgroundFilter,
  12. EdgeInsetsGeometry? padding,
  13. IconThemeData? iconStyle,
  14. double? iconSpacing,
  15. TextStyle? titleTextStyle,
  16. double? titleSpacing,
  17. TextStyle? descriptionTextStyle,
  18. double? suffixSpacing,
})

Returns a copy of this FToastStyle with the given properties replaced.

Where possible, it is strongly recommended to use the CLI to generate a style and directly modify the style.

enterExitDuration

The toast's entrance & exit animation duration. Defaults to 400ms.

enterCurve

The toast's entrance animation curve. Defaults to Curves.easeOutCubic.

exitCurve

The toast's exit animation curve. Defaults to Curves.easeOutCubic.

entranceExitOpacity

The toast's initial opacity when it enters, and the target opacity when it exits.

Defaults to 0. Set to 1.0 to remove the fade-in/out effect.

Contract

Throws AssertionError if the value is not in [0, 1].

transitionDuration

The toast's transition between indexes animation duration. Defaults to 400ms.

transitionCurve

The toast's transition animation curve. Defaults to Curves.easeInOutCubic.

swipeCompletionDuration

The toast's swipe completion animation duration. Defaults to 150ms.

swipeCompletionCurve

The toast's swipe completion animation curve. Defaults to Curves.easeInCubic.

constraints

The toast's constraints. Defaults to BoxConstraints(maxHeight: 250, maxWidth: 400).

decoration

The toast's decoration.

backgroundFilter

An optional background filter. This only takes effect if the decoration has a transparent or translucent background color.

This is typically combined with a transparent/translucent background to create a glassmorphic effect.

There will be a flicker after the toast's fade-in entrance when a blur background filter is applied. This is due to https://github.com/flutter/flutter/issues/31706.

Examples

// Blurred
ImageFilter.blur(sigmaX: 5, sigmaY: 5);

// Solid color
ColorFilter.mode(Colors.white, BlendMode.srcOver);

// Tinted
ColorFilter.mode(Colors.white.withValues(alpha: 0.5), BlendMode.srcOver);

// Blurred & tinted
ImageFilter.compose(
  outer: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
  inner: ColorFilter.mode(Colors.white.withValues(alpha: 0.5), BlendMode.srcOver),
);

padding

The toast content's padding. Defaults to EdgeInsets.all(16).

iconStyle

The style of the toast's prefix icon.

iconSpacing

The spacing between the icon and the title. Defaults to 10.0.

titleTextStyle

The title's text style.

titleSpacing

The spacing between the title and description Defaults to 5.0.

descriptionTextStyle

The description's text style.

suffixSpacing

The spacing between the icon and the title. Defaults to 12.0.

Implementation

@useResult
FToastStyle copyWith({
  Duration? enterExitDuration,
  Curve? enterCurve,
  Curve? exitCurve,
  double? entranceExitOpacity,
  Duration? transitionDuration,
  Curve? transitionCurve,
  Duration? swipeCompletionDuration,
  Curve? swipeCompletionCurve,
  BoxConstraints? constraints,
  BoxDecoration? decoration,
  ImageFilter? backgroundFilter,
  EdgeInsetsGeometry? padding,
  IconThemeData? iconStyle,
  double? iconSpacing,
  TextStyle? titleTextStyle,
  double? titleSpacing,
  TextStyle? descriptionTextStyle,
  double? suffixSpacing,
}) => FToastStyle(
  enterExitDuration: enterExitDuration ?? this.enterExitDuration,
  enterCurve: enterCurve ?? this.enterCurve,
  exitCurve: exitCurve ?? this.exitCurve,
  entranceExitOpacity: entranceExitOpacity ?? this.entranceExitOpacity,
  transitionDuration: transitionDuration ?? this.transitionDuration,
  transitionCurve: transitionCurve ?? this.transitionCurve,
  swipeCompletionDuration: swipeCompletionDuration ?? this.swipeCompletionDuration,
  swipeCompletionCurve: swipeCompletionCurve ?? this.swipeCompletionCurve,
  constraints: constraints ?? this.constraints,
  decoration: decoration ?? this.decoration,
  backgroundFilter: backgroundFilter ?? this.backgroundFilter,
  padding: padding ?? this.padding,
  iconStyle: iconStyle ?? this.iconStyle,
  iconSpacing: iconSpacing ?? this.iconSpacing,
  titleTextStyle: titleTextStyle ?? this.titleTextStyle,
  titleSpacing: titleSpacing ?? this.titleSpacing,
  descriptionTextStyle: descriptionTextStyle ?? this.descriptionTextStyle,
  suffixSpacing: suffixSpacing ?? this.suffixSpacing,
);