ToastLayer constructor

const ToastLayer({
  1. Key? key,
  2. required Widget child,
  3. int maxStackedEntries = 3,
  4. EdgeInsetsGeometry? padding,
  5. ExpandMode expandMode = ExpandMode.expandOnHover,
  6. Offset? collapsedOffset,
  7. double collapsedScale = 0.9,
  8. Curve expandingCurve = Curves.easeOutCubic,
  9. Duration expandingDuration = const Duration(milliseconds: 500),
  10. double collapsedOpacity = 1,
  11. double entryOpacity = 0.0,
  12. double spacing = 8,
  13. BoxConstraints? toastConstraints,
})

Creates a ToastLayer.

The child parameter is required as the content to wrap with toast functionality. All other parameters have sensible defaults but can be customized to match specific design requirements.

Parameters:

  • child (Widget, required): Content to wrap with toast capabilities
  • maxStackedEntries (int, default: 3): Maximum visible toast count
  • padding (EdgeInsetsGeometry?, optional): Toast area padding override
  • expandMode (ExpandMode, default: expandOnHover): Stack expansion behavior
  • collapsedOffset (Offset?, optional): Background toast positioning offset
  • collapsedScale (double, default: 0.9): Background toast size reduction
  • expandingCurve (Curve, default: easeOutCubic): Expansion animation curve
  • expandingDuration (Duration, default: 500ms): Expansion animation timing
  • collapsedOpacity (double, default: 1.0): Background toast visibility
  • entryOpacity (double, default: 0.0): Toast entrance starting opacity
  • spacing (double, default: 8.0): Gap between expanded toast entries
  • toastConstraints (BoxConstraints?, optional): Individual toast size limits

Example:

ToastLayer(
  maxStackedEntries: 5,
  expandMode: ExpandMode.expandOnTap,
  spacing: 12.0,
  child: MaterialApp(home: HomePage()),
);

Implementation

const ToastLayer({
  super.key,
  required this.child,
  this.maxStackedEntries = 3,
  this.padding,
  this.expandMode = ExpandMode.expandOnHover,
  this.collapsedOffset,
  this.collapsedScale = 0.9,
  this.expandingCurve = Curves.easeOutCubic,
  this.expandingDuration = const Duration(milliseconds: 500),
  this.collapsedOpacity = 1,
  this.entryOpacity = 0.0,
  this.spacing = 8,
  this.toastConstraints,
});