【发布时间】:2020-01-16 10:51:07
【问题描述】:
抱歉,我刚开始学习 Flutter 并制作了一个简单的页面。我想检查是否有互联网,如果没有,我想在启动屏幕上使用 rFlutterPackage 显示弹出警报(如果可能)。如果我不能使用闪屏,我可以重定向到新页面并只显示对话框。
只有在按下按钮时才会触发警报对话框?
一旦用户点击警报按钮,我如何关闭应用程序?
如何使用对话框显示在初始屏幕顶部,以便用户点击?
主页
import 'package:connectivity/connectivity.dart';
import 'package:flutter/material.dart';
import 'package:algorithm_send_location/pages/home_screen.dart';
import 'package:algorithm_send_location/pages/splash_screen.dart';
import 'package:algorithm_send_location/pages/initial_warning.dart';
var routes = <String, WidgetBuilder>{
"/home": (BuildContext context) => HomeScreen(),
};
void main() => runApp(new MaterialApp(
theme:
ThemeData(primaryColor: Colors.amber, accentColor: Colors.green[200]),
debugShowCheckedModeBanner: false,
home: _checkConnectivity ? SplashScreen() : WarningScreen(),
routes: routes));
get _checkConnectivity async {
var internetResult = await Connectivity().checkConnectivity();
if (internetResult == ConnectivityResult.none) {
return false;
} else if (internetResult == ConnectivityResult.wifi ||
internetResult == ConnectivityResult.mobile) {
return false;
//return true;
}
}
我想使用提醒
Alert(
context: context,
type: AlertType.warning,
title: "RFLUTTER ALERT",
desc: "Flutter is more awesome with RFlutter Alert.",
buttons: [
DialogButton(
child: Text(
"There is no internet Connection",
style: TextStyle(color: Colors.white, fontSize: 20),
),
onPressed: () => Navigator.pop(context),
color: Color.fromRGBO(0, 179, 134, 1.0),
),
],
).show();
【问题讨论】:
标签: flutter