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> {
],
),
),
));
)));
}
}

View File

@@ -1,5 +1,7 @@
import 'dart:io';
import 'package:camera/camera.dart';
import 'package:cathaypay_mobile/Home/HomePage.dart';
import 'package:cathaypay_mobile/Login/Login.dart';
@@ -26,6 +28,7 @@ Future<void> main() async {
Intl.defaultLocale = "th";
initializeDateFormatting();
CameraApp = await availableCameras();
HttpOverrides.global = MyHttpOverrides();
runApp(
EasyLocalization(
supportedLocales: [Locale('en'), Locale('th')],
@@ -89,3 +92,10 @@ class MyApp extends StatelessWidget {
extension E on String {
String lastChars(int n) => substring(length - n);
}
class MyHttpOverrides extends HttpOverrides{
@override
HttpClient createHttpClient(SecurityContext? context){
return super.createHttpClient(context)
..badCertificateCallback = (X509Certificate cert, String host, int port)=> true;
}
}