Start an Alert by opening page with Flutter web
303
Call your method in the initState()
class StatefulWrapper extends StatefulWidget {
@override
_StatefulWrapperState createState() => _StatefulWrapperState();
}
class _StatefulWrapperState extends State<StatefulWrapper> {
@override
void initState() {
Alert(
context: context,
title: "JOJOJO",
desc: "Flutter is more awesome with RFlutter Alert.",
).show();
super.initState();
}
@override
Widget build(BuildContext context) {
return Container();
}
}
Author by
Charles Down
Updated on December 29, 2022Comments
-
Charles Down over 1 year
Final Code which solved it
@override void initState() { super.initState(); Future.delayed(Duration.zero, () { Alert( context: context, title: "JOJOJO", desc: "Flutter is more awesome with RFlutter Alert.", ).show(); }); }
I want to build an Flutter alert into my web app and when I open the website I want to pop it up immediately. The alert is build with the rflutter_alert package.
Does somebody have a solution to open this alert automatically?
Code of the Alert
_onBasicAlertPressed(context) { Alert( context: context, title: "JOJOJO", desc: "Flutter is more awesome with RFlutter Alert.", ).show(); }
With the init State
Apparently it doesn't work when I just put it into the init state. However another function works with this way, the function that i want to activate for now only works by using onpressed in a button.
@override void initState() { Alert( context: context, title: "JOJOJO", desc: "Flutter is more awesome with RFlutter Alert.", ).show(); super.initState(); callSendData(); }
-
Charles Down about 3 yearsOk i tried this but it didn't worked out. I updated my question
-
Charles Down about 3 yearsOk i got a Problem but it worked out now Solutino: stackoverflow.com/questions/56395081/…