1

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();
}
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Charles Down
  • 427
  • 1
  • 6
  • 15

1 Answers1

2

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

What is init state?

Ibrahim Ali
  • 2,083
  • 2
  • 15
  • 36
  • Ok i tried this but it didn't worked out. I updated my question – Charles Down Apr 18 '21 at 00:56
  • Ok i got a Problem but it worked out now Solutino: https://stackoverflow.com/questions/56395081/unhandled-exception-inheritfromwidgetofexacttype-localizationsscope-or-inheri – Charles Down Apr 18 '21 at 01:15