diff --git a/lib/qr_code_screen.dart b/lib/qr_code_screen.dart index 05f9295..31f7fb8 100644 --- a/lib/qr_code_screen.dart +++ b/lib/qr_code_screen.dart @@ -1,3 +1,4 @@ +import 'package:app_settings/app_settings.dart'; import 'package:flutter/material.dart'; import 'package:mobile_scanner/mobile_scanner.dart'; @@ -66,6 +67,36 @@ class _QrCodeScreenState extends State { controller: _controller, fit: BoxFit.cover, onDetect: _onDetect, + errorBuilder: (context, error) { + return Center( + child: Padding( + padding: const EdgeInsets.all(24.0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon(Icons.videocam_off_outlined, size: 64), + const SizedBox(height: 16), + Text( + error.errorCode == MobileScannerErrorCode.permissionDenied + ? "Camera Permission Has Been Denied" + : error.errorDetails?.message ?? "Camera Error", + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.bodyLarge, + ), + const SizedBox(height: 24), + FilledButton.icon( + onPressed: + () => AppSettings.openAppSettings( + type: AppSettingsType.settings, + ), + icon: const Icon(Icons.settings), + label: Text("Open Settings"), + ), + ], + ), + ), + ); + }, ), ); } diff --git a/pubspec.lock b/pubspec.lock index 4ba9485..f750490 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -41,6 +41,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.4" + app_settings: + dependency: "direct main" + description: + name: app_settings + sha256: "64d50e666fd96ae90301bf71205f05019286f940ad6f5fed3d1be19c6af7546a" + url: "https://pub.dev" + source: hosted + version: "7.0.0" archive: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 42d28b8..1dbb912 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -25,6 +25,7 @@ dependencies: mobile_scanner: ^7.1.4 flutter_secure_storage: ^10.0.0 app_links: ^7.0.0 + app_settings: ^7.0.0 dev_dependencies: flutter_test: