fix: 修正安卓用戶使用返回鍵退回不正當頁面

This commit is contained in:
JingChiang 2024-09-03 01:24:05 +08:00
parent 939d8ddef0
commit dc1a6534bc
2 changed files with 183 additions and 176 deletions

View File

@ -29,7 +29,8 @@ class _HomePageState extends State<HomePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return PopScope(
child: Scaffold(
body: Center( body: Center(
child: Column( child: Column(
children: [ children: [
@ -118,6 +119,8 @@ class _HomePageState extends State<HomePage> {
], ],
), ),
), ),
),
canPop: false,
); );
} }

View File

@ -69,7 +69,9 @@ class _LoginPageState extends State<LoginPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
debugPaintSizeEnabled=false; debugPaintSizeEnabled=false;
return Scaffold( //by use PopScope and disable can Pop avoid android user pop back by back button
return PopScope(
child: Scaffold(
//appBar: AppBar( //appBar: AppBar(
//title: Text('Demo'), //title: Text('Demo'),
//backgroundColor: Color(0xFF81D4FA), //backgroundColor: Color(0xFF81D4FA),
@ -170,6 +172,8 @@ class _LoginPageState extends State<LoginPage> {
), ),
), ),
), ),
),
canPop: false,
); );
} }
void loginBtn() async { void loginBtn() async {