Showing
1 changed file
with
16 additions
and
0 deletions
| 1 | +import 'dart:io'; | ||
| 2 | + | ||
| 1 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
| 2 | import 'package:flutter/services.dart'; | 4 | import 'package:flutter/services.dart'; |
| 3 | import 'package:flutter_easyrefresh/easy_refresh.dart'; | 5 | import 'package:flutter_easyrefresh/easy_refresh.dart'; |
| @@ -14,9 +16,11 @@ import 'package:one_key/widgets/h_empty_view.dart'; | @@ -14,9 +16,11 @@ import 'package:one_key/widgets/h_empty_view.dart'; | ||
| 14 | import 'package:one_key/widgets/round_button.dart'; | 16 | import 'package:one_key/widgets/round_button.dart'; |
| 15 | import 'package:one_key/widgets/system_app_bar.dart'; | 17 | import 'package:one_key/widgets/system_app_bar.dart'; |
| 16 | import 'package:one_key/widgets/v_empty_view.dart'; | 18 | import 'package:one_key/widgets/v_empty_view.dart'; |
| 19 | +import 'package:permission_handler/permission_handler.dart'; | ||
| 17 | import 'package:provider/provider.dart'; | 20 | import 'package:provider/provider.dart'; |
| 18 | import 'package:barcode_scan2/barcode_scan2.dart'; | 21 | import 'package:barcode_scan2/barcode_scan2.dart'; |
| 19 | 22 | ||
| 23 | +import '../../app.dart'; | ||
| 20 | import '../../provider/marketing_center_provider.dart'; | 24 | import '../../provider/marketing_center_provider.dart'; |
| 21 | import '../../utils/dialog_util.dart'; | 25 | import '../../utils/dialog_util.dart'; |
| 22 | import '../../utils/misc.dart'; | 26 | import '../../utils/misc.dart'; |
| @@ -124,6 +128,18 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin { | @@ -124,6 +128,18 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin { | ||
| 124 | 128 | ||
| 125 | Future<void> _scan() async { | 129 | Future<void> _scan() async { |
| 126 | try { | 130 | try { |
| 131 | + //全局提示权限使用目的 | ||
| 132 | + if (Platform.isAndroid) { | ||
| 133 | + PermissionStatus permissionStatus = await Permission.camera.status; | ||
| 134 | + | ||
| 135 | + if (permissionStatus != PermissionStatus.permanentlyDenied) { | ||
| 136 | +//全局提示权限使用目的 | ||
| 137 | + BuildContext context = App.navigatorKey.currentState.overlay.context; | ||
| 138 | + DialogUtil.showAuthorityDestination( | ||
| 139 | + context, 'h_camera', '相机权限使用说明', '用于扫描二维码进行优惠券核销'); | ||
| 140 | + } | ||
| 141 | + } | ||
| 142 | + | ||
| 127 | final result = await BarcodeScanner.scan( | 143 | final result = await BarcodeScanner.scan( |
| 128 | options: ScanOptions( | 144 | options: ScanOptions( |
| 129 | strings: {'cancel': '退出', 'flash_on': '开闪光灯', 'flash_off': '关闪光灯'}, | 145 | strings: {'cancel': '退出', 'flash_on': '开闪光灯', 'flash_off': '关闪光灯'}, |
-
Please register or login to post a comment