在颤动中按下移动后退按钮后,网站应用程序未退出
Website App is not Exiting after pressing mobile back button in flutter
我使应用程序在导航栏中具有功能。(重新加载网页)(返回网页)。(浏览网页的转发。)
我面临的问题我想退出应用程序它没有退出移动返回 button.In 模拟器应用程序正在退出但在实际 android 设备它没有退出。我怎样才能退出应用程序。我是 flutter 的新手,所以不知道该怎么做。
代码:main.dart
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,
),
],
),
),
},
);
}
}
完成 flutter clean 命令后,它正在正常退出。
我使应用程序在导航栏中具有功能。(重新加载网页)(返回网页)。(浏览网页的转发。) 我面临的问题我想退出应用程序它没有退出移动返回 button.In 模拟器应用程序正在退出但在实际 android 设备它没有退出。我怎样才能退出应用程序。我是 flutter 的新手,所以不知道该怎么做。
代码:main.dart
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,
),
],
),
),
},
);
}
}
完成 flutter clean 命令后,它正在正常退出。