Ad
Start An Alert By Opening Page With Flutter Web
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();
}
Ad
Answer
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();
}
}
Ad
source: stackoverflow.com
Related Questions
- → How do you create a 12 or 24 mnemonics code for multiple cryptocurrencies (ETH, BTC and so on..)
- → Flutter: input text field don't work properly in a simple example..... where am I wrong?
- → Can I customize the code formatting of Dart code in Atom?
- → Is it possible to develop iOS apps with Flutter on a Linux virtual machine?
- → Display SnackBar in Flutter
- → JSON ObjectMapper in Flutter
- → Material flutter app source code
- → TabBarSelection No such method error
- → How do I set the animation color of a LinearProgressIndicator?
- → Add different routes/screens to Flutter app
- → Is there a way to get the size of an existing widget?
- → How to share a file using flutter
- → Is there an easy way to find particular text built from RichText in a Flutter test?
Ad