createView static method
void
createView()
Implementation
static void createView(
String msg, /// the message you want to show as toast
BuildContext context,
int? duration, /// duration : how long do you want to show the message
int? position, /// position : where do you want to show the toast message, you can pass bottom, center, top or any defined value
Color background, /// defines the background color of toast message
TextStyle textStyle, /// for toast message styling
double backgroundRadius, /// you can apply toast message background radius
Border? border, /// you can specify background border
bool? rootNavigator) async {
overlayState = Overlay.of(context, rootOverlay: rootNavigator ?? false);
_overlayEntry = new OverlayEntry(
builder: (BuildContext context) => FlutterToastrWidget(
widget: Container(
width: MediaQuery.of(context).size.width,
child: Container(
alignment: Alignment.center,
width: MediaQuery.of(context).size.width,
child: Container(
decoration: BoxDecoration(
color: background,
borderRadius: BorderRadius.circular(backgroundRadius),
border: border,
),
margin: EdgeInsets.symmetric(horizontal: 20),
padding: EdgeInsets.fromLTRB(16, 10, 16, 10),
child: Text(msg, softWrap: true, style: textStyle),
)),
),
position: position),
);
_isVisible = true;
overlayState!.insert(_overlayEntry!);
await new Future.delayed(Duration(
seconds: duration == null ? FlutterToastr.lengthShort : duration));
dismiss();
}