createView static method
void
createView(
- String text,
- BuildContext context,
- int? toastDuration,
- GFToastPosition? toastPosition,
- Color backgroundColor,
- TextStyle textStyle,
- double toastBorderRadius,
- Border? border,
- dynamic trailing,
Implementation
static void createView(
String text,
BuildContext context,
int? toastDuration,
GFToastPosition? toastPosition,
Color backgroundColor,
TextStyle textStyle,
double toastBorderRadius,
Border? border,
// ignore: type_annotate_public_apis
trailing) async {
overlayState = Overlay.of(context, rootOverlay: false);
final Widget toastChild = ToastCard(
Container(
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: BorderRadius.circular(toastBorderRadius),
border: border,
),
margin: const EdgeInsets.symmetric(horizontal: 16),
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
child: trailing == null
? Text(text, softWrap: true, style: textStyle)
: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(text, style: textStyle),
),
const SizedBox(
width: 6,
),
trailing
],
),
),
Duration(seconds: toastDuration ?? 2),
fadeDuration: 500);
_overlayEntry = OverlayEntry(
builder: (BuildContext context) =>
_showWidgetBasedOnPosition(toastChild, toastPosition));
_isVisible = true;
overlayState!.insert(_overlayEntry!);
await Future.delayed(Duration(seconds: toastDuration ?? 2));
await dismiss();
}