我正在创建的应用程序存在问题,当用户退出应用程序后,通过单击“后退”按钮,该页面会松开当前页面。即使如此,用户也没有清除他的手机缓存。
关于如何处理此问题的任何建议?
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
brightness: Brightness.light,
primaryColor: Colors.red,
fontFamily: 'Lato',
),
home: new SplashScreen(),
);
}
}
class SplashScreen extends StatefulWidget {
SplashScreen({Key key}) : super(key: key);
@override
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
@override
void initState() {
Timer(Duration(seconds: 2), () {
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (context) => Login()));
});
super.initState();
}
@override
Widget build(BuildContext context) {
return SplashScreenContainer();
}
}
class Login extends StatelessWidget {
const Login({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return FlatButton(
onPressed: () {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => Home()),
ModalRoute.withName("/Home"));
},
child: Text("Login"),
);
}
}
class Home extends StatelessWidget {
const Home({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return HomeBase();
}
}
当用户使用HomePage时,请单击“后退”按钮。他将退出应用程序。然后当他再次打开时,他需要启动屏幕