showToast function
ToastFuture
showToast(
- String msg, {
- BuildContext? context,
- BuildContextPredicate buildContextPredicate = _defaultContextPredicate,
- Duration? duration,
- ToastPosition? position,
- Color? backgroundColor,
- double? radius,
- VoidCallback? onDismiss,
- bool? dismissOtherToast,
- OKToastAnimationBuilder? animationBuilder,
- Duration? animationDuration,
- Curve? animationCurve,
- BoxConstraints? constraints,
- EdgeInsetsGeometry? margin = const EdgeInsets.all(50),
- TextDirection? textDirection,
- EdgeInsetsGeometry? textPadding,
- TextAlign? textAlign,
- TextStyle? textStyle,
- int? textMaxLines,
- TextOverflow? textOverflow,
Show toast with msg
,
Implementation
ToastFuture showToast(
String msg, {
BuildContext? context,
BuildContextPredicate buildContextPredicate = _defaultContextPredicate,
Duration? duration,
ToastPosition? position,
Color? backgroundColor,
double? radius,
VoidCallback? onDismiss,
bool? dismissOtherToast,
OKToastAnimationBuilder? animationBuilder,
Duration? animationDuration,
Curve? animationCurve,
BoxConstraints? constraints,
EdgeInsetsGeometry? margin = const EdgeInsets.all(50),
TextDirection? textDirection,
EdgeInsetsGeometry? textPadding,
TextAlign? textAlign,
TextStyle? textStyle,
int? textMaxLines,
TextOverflow? textOverflow,
}) {
if (context == null) {
_throwIfNoContext(_contextMap.values, 'showToast');
}
context ??= buildContextPredicate(_contextMap.values);
final ToastTheme theme = ToastTheme.of(context);
position ??= theme.position;
backgroundColor ??= theme.backgroundColor;
radius ??= theme.radius;
textDirection ??= theme.textDirection;
textPadding ??= theme.textPadding;
textAlign ??= theme.textAlign;
textStyle ??= theme.textStyle;
textMaxLines ??= theme.textMaxLines;
textOverflow ??= theme.textOverflow;
final Widget widget = Container(
constraints: constraints,
margin: margin,
padding: textPadding,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(radius),
color: backgroundColor,
),
child: ClipRect(
child: Text(
msg,
style: textStyle,
textAlign: textAlign,
maxLines: textMaxLines,
overflow: textOverflow,
),
),
);
return showToastWidget(
widget,
context: context,
buildContextPredicate: buildContextPredicate,
duration: duration,
onDismiss: onDismiss,
position: position,
dismissOtherToast: dismissOtherToast,
textDirection: textDirection,
animationBuilder: animationBuilder,
animationDuration: animationDuration,
animationCurve: animationCurve,
);
}