import 'package:flutter/cupertino.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/view_widget/request_permission.dart'; import 'package:permission_handler/permission_handler.dart'; // import 'package:qrscan/qrscan.dart' as scanner; class Scan { static toScan(context, id, tenantCode, storeName) async { if (await Permission.camera.isPermanentlyDenied) { showCupertinoDialog( context: context, builder: (context) { return RequestPermission( "assets/image/icon_camera_permission_tips.webp", S.of(context).ninxiangjiquanxianweikaiqi, S.of(context).weilekaipaizhaoxuanzhetouxiang, S.of(context).kaiqiquanxian, (result) async { if (result) { await openAppSettings(); } }, heightRatioWithWidth: 0.82, ); }); } else if (await Permission.camera.isGranted) { var result = await Navigator.of(context).pushNamed('/router/qr_scan'); // String result = await scanner.scan(); if (result != null && result != "") { Uri uri = Uri.parse(result); String table = uri.queryParameters["tableId"]; if (table != null && table != "") { int tableId = int.tryParse(table); Navigator.of(context).pushNamed( '/router/store_order', arguments: { "id": id, "tenant": tenantCode, "storeName": storeName, "tableId": tableId, }, ); } } } else { await Permission.camera.request(); } } }