ToastLayer constructor
const
ToastLayer({
- Key? key,
- required Widget child,
- int maxStackedEntries = 3,
- EdgeInsetsGeometry? padding,
- ExpandMode expandMode = ExpandMode.expandOnHover,
- Offset? collapsedOffset,
- double collapsedScale = 0.9,
- Curve expandingCurve = Curves.easeOutCubic,
- Duration expandingDuration = const Duration(milliseconds: 500),
- double collapsedOpacity = 1,
- double entryOpacity = 0.0,
- double spacing = 8,
- 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 capabilitiesmaxStackedEntries(int, default: 3): Maximum visible toast countpadding(EdgeInsetsGeometry?, optional): Toast area padding overrideexpandMode(ExpandMode, default: expandOnHover): Stack expansion behaviorcollapsedOffset(Offset?, optional): Background toast positioning offsetcollapsedScale(double, default: 0.9): Background toast size reductionexpandingCurve(Curve, default: easeOutCubic): Expansion animation curveexpandingDuration(Duration, default: 500ms): Expansion animation timingcollapsedOpacity(double, default: 1.0): Background toast visibilityentryOpacity(double, default: 0.0): Toast entrance starting opacityspacing(double, default: 8.0): Gap between expanded toast entriestoastConstraints(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,
});