通过使用 Flutter web 打开页面来启动警报
Start an Alert by opening page with Flutter web
解决它的最终代码
@override
void initState() {
super.initState();
Future.delayed(Duration.zero, () {
Alert(
context: context,
title: "JOJOJO",
desc: "Flutter is more awesome with RFlutter Alert.",
).show();
});
}
我想在我的 Web 应用程序中构建一个 Flutter 警报,当我打开网站时,我想立即弹出它。
警报是使用 rflutter_alert 包构建的。
有人有自动打开此警报的解决方案吗?
警报代码
_onBasicAlertPressed(context) {
Alert(
context: context,
title: "JOJOJO",
desc: "Flutter is more awesome with RFlutter Alert.",
).show();
}
与初始状态
显然当我只是将其置于初始状态时它不起作用。
然而另一个功能是这样工作的,我现在想激活的功能只能通过在按钮中使用 onpressed 来工作。
@override
void initState() {
Alert(
context: context,
title: "JOJOJO",
desc: "Flutter is more awesome with RFlutter Alert.",
).show();
super.initState();
callSendData();
}
在 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();
}
}
解决它的最终代码
@override
void initState() {
super.initState();
Future.delayed(Duration.zero, () {
Alert(
context: context,
title: "JOJOJO",
desc: "Flutter is more awesome with RFlutter Alert.",
).show();
});
}
我想在我的 Web 应用程序中构建一个 Flutter 警报,当我打开网站时,我想立即弹出它。 警报是使用 rflutter_alert 包构建的。
有人有自动打开此警报的解决方案吗?
警报代码
_onBasicAlertPressed(context) {
Alert(
context: context,
title: "JOJOJO",
desc: "Flutter is more awesome with RFlutter Alert.",
).show();
}
与初始状态
显然当我只是将其置于初始状态时它不起作用。 然而另一个功能是这样工作的,我现在想激活的功能只能通过在按钮中使用 onpressed 来工作。
@override
void initState() {
Alert(
context: context,
title: "JOJOJO",
desc: "Flutter is more awesome with RFlutter Alert.",
).show();
super.initState();
callSendData();
}
在 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();
}
}