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();
}
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();
}
}