bug fixed

This commit is contained in:
nutchayut
2024-12-25 17:44:05 +07:00
parent f6b69c6c56
commit 5f810de336
30 changed files with 2686 additions and 2591 deletions

View File

@@ -27,7 +27,7 @@ import '../utils/utils.dart';
Profile? profile;
String tokenAdmin = "";
bool _canPop = false;
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@@ -92,7 +92,9 @@ class _HomePageState extends State<HomePage> {
clearProfile() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString("access_token", "");
_canPop = true;
Navigator.popUntil(context, ModalRoute.withName('/'));
_canPop = false;
}
lockTest() {
@@ -223,7 +225,17 @@ class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
return PopScope(
canPop: _canPop, // <== set a bool var or set it to false
onPopInvoked: (bool didPop) async {
if (didPop) {
return;
}
if (Navigator.of(context).canPop()) {
Navigator.of(context).pop(context);
}
},
child: Scaffold(
body: SafeArea(
child: SmartRefresher(
onRefresh: () {
@@ -255,6 +267,7 @@ class _HomePageState extends State<HomePage> {
children: [
InkWell(
onTap: () {
clearProfile();
},
child: Icon(
@@ -562,7 +575,7 @@ class _HomePageState extends State<HomePage> {
],
),
),
));
)));
}
}