Android 在Flatter中按移动后退按钮后,网站应用程序未退出
我使应用程序在导航栏中具有功能。(重新加载网页)(返回网页)。(浏览网页的前面。) 我面临的问题我想退出应用程序,但它没有使用移动后退按钮退出。在emulator中,应用程序正在退出,但在实际的android设备中,它没有退出。如何退出应用程序。我是新手,所以不知道该怎么做 代码:main.dartAndroid 在Flatter中按移动后退按钮后,网站应用程序未退出,android,flutter,flutter-layout,flutter-plugin,flutterwebviewplugin,Android,Flutter,Flutter Layout,Flutter Plugin,Flutterwebviewplugin,我使应用程序在导航栏中具有功能。(重新加载网页)(返回网页)。(浏览网页的前面。) 我面临的问题我想退出应用程序,但它没有使用移动后退按钮退出。在emulator中,应用程序正在退出,但在实际的android设备中,它没有退出。如何退出应用程序。我是新手,所以不知道该怎么做 代码:main.dart import 'package:flutter/material.dart'; import 'package:flutter_webview_plugin/flutter_webview_plug
import 'package:flutter/material.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
main()=>runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
int currentTab = 1;
void splitScreen(int i) {
switch (i) {
case 0:
FlutterWebviewPlugin().close();
break;
case 1:
FlutterWebviewPlugin().reload();
break;
case 2:
FlutterWebviewPlugin().goForward();
break;
}
}
@override
Widget build(BuildContext context) {
return new MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter WebView Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
routes: {
"/": (_) => new WebviewScaffold(
url: "https://www.lucrurile-care-conteaza-cel-mai-mult.ro/",
// appBar: new AppBar(
// title: new Text("Widget webview"),
// ),
withZoom: true,
withLocalStorage: true,
hidden: true,
initialChild: Center(
child: Container(
height: 210,
width: 200,
decoration: BoxDecoration(
// shape: BoxShape.circle,
// boxShadow: [
// BoxShadow(
// color: Colors.black87,
// blurRadius: 10.0,
// spreadRadius: 0.5,
// offset: Offset.fromDirection(10)),
// ],
image: DecorationImage(
image: AssetImage(
'images/3f2c979b214d06e9caab8ba8326864f3.gif',
),
fit: BoxFit.cover),
),
),
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: currentTab,
onTap: (i) {
splitScreen(i);
setState(() {
currentTab = i;
});
},
items: [
BottomNavigationBarItem(
icon: Icon(Icons.arrow_back_ios),
title: Text('Back'),
backgroundColor: Colors.blue,
),
BottomNavigationBarItem(
icon: Icon(Icons.refresh),
title: Text('Refresh'),
backgroundColor: Colors.blue,
), BottomNavigationBarItem(
icon: Icon(Icons.arrow_forward_ios),
title: Text('Forward'),
backgroundColor: Colors.blue,
),
],
),
),
},
);
}
}
导入“包装:颤振/材料.省道”;
导入“包:flatter_webview_plugin/flatter_webview_plugin.dart”;
main()=>runApp(MyApp());
类MyApp扩展了StatefulWidget{
@凌驾
_MyAppState createState()=>\u MyAppState();
}
类MyAppState扩展了状态{
int currentTab=1;
空分屏(int i){
开关(一){
案例0:
FlatterWebViewPlugin().close();
打破
案例1:
flatterWebViewPlugin().reload();
打破
案例2:
flatterWebViewPlugin().goForward();
打破
}
}
@凌驾
小部件构建(构建上下文){
返回新材料PP(
debugShowCheckedModeBanner:false,
标题:“颤振网络视图演示”,
主题:新主题数据(
主样本:颜色。蓝色,
),
路线:{
“/”:()=>新建WebviewScaffold(
url:“https://www.lucrurile-care-conteaza-cel-mai-mult.ro/",
//appBar:新的appBar(
//标题:新文本(“Widget webview”),
// ),
withZoom:true,
withLocalStorage:true,
隐藏:是的,
孩子:中心(
子:容器(
身高:210,
宽度:200,
装饰:盒子装饰(
//形状:BoxShape.circle,
//boxShadow:[
//箱形阴影(
//颜色:颜色。黑色87,
//半径:10.0,
//扩展半径:0.5,
//偏移量:偏移量。从方向(10)),
// ],
图像:装饰图像(
图片:资产评估(
'images/3f2c979b214d06e9caab8ba8326864f3.gif',
),
安装:BoxFit.盖),
),
),
),
底部导航栏:底部导航栏(
currentIndex:currentTab,
onTap:(一){
分屏(i);
设置状态(){
currentTab=i;
});
},
项目:[
底部导航气压计(
图标:图标(图标、箭头、背面),
标题:文本(“背面”),
背景颜色:Colors.blue,
),
底部导航气压计(
图标:图标(Icons.refresh),
标题:文本(“刷新”),
背景颜色:Colors.blue,
),底部导航栏(
图标:图标(图标。箭头\前进\ ios),
标题:文本(“转发”),
背景颜色:Colors.blue,
),
],
),
),
},
);
}
}
完成颤振清理命令后,它将正确退出