We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
flutter: 3.0.2 ai_barcode: 3.2.2
After opening scanner screen in IOS scan area border isn't created and exception is thrown .
Also, after toggle flash, scan doesn't work.
main.dart
import 'package:flutter/material.dart'; import 'scanner_screen.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const MaterialApp( home: HomePage(title: 'Home page'), ); } } class HomePage extends StatelessWidget { const HomePage({Key? key, required this.title}) : super(key: key); final String title; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(title), ), body: Center( child:ElevatedButton(onPressed: () {Navigator.push(context, MaterialPageRoute(builder: (context) => const ScannerScreen()));}, child: const Text('Open scanner')) )); } }
scanner_screen.dart
import 'dart:io'; import 'package:ai_barcode/ai_barcode.dart'; import 'package:flutter/material.dart'; import 'package:permission_handler/permission_handler.dart'; class ScannerScreen extends StatefulWidget { const ScannerScreen({Key? key}) : super(key: key); @override State<ScannerScreen> createState() => _ScannerScreenState(); } class _ScannerScreenState extends State<ScannerScreen> { late ScannerController _scannerController; bool _isFlashOn = false; String? barcode; @override void initState() { super.initState(); _scannerController = ScannerController(scannerResult: (barcode) => setState(()=> this.barcode = barcode), scannerViewCreated: () { if (Platform.isIOS) { Future.delayed(const Duration(seconds: 2), () { _scannerController.startCamera(); _scannerController.startCameraPreview(); }); } else { _scannerController.startCamera(); _scannerController.startCameraPreview(); } }); } @override Widget build(BuildContext context) => SafeArea( child: Scaffold( body: FutureBuilder<bool?>( future: Permission.camera.request().isGranted, builder: (_, snapshot) { if (snapshot.hasData) { return Stack( children: <Widget>[ PlatformAiBarcodeScannerWidget( platformScannerController: _scannerController, ), Padding( padding: const EdgeInsets.only(top: 8), child: IconButton( padding: const EdgeInsets.only(left: 14), onPressed: () { _scannerController.toggleFlash(); setState(() => _isFlashOn = !_isFlashOn); }, icon: Icon( _isFlashOn ? Icons.flash_on : Icons.flash_off, color: Colors.white, size: 40, ))), Align(alignment: Alignment.bottomCenter,child: Text(barcode == null ? 'Scan a code' : barcode!, style: const TextStyle(color: Colors.red, fontSize: 24))) ], ); } return const Center(child: CircularProgressIndicator()); }, ), ), ); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
flutter: 3.0.2
ai_barcode: 3.2.2
After opening scanner screen in IOS scan area border isn't created and exception is thrown .
Also, after toggle flash, scan doesn't work.
main.dart
scanner_screen.dart
The text was updated successfully, but these errors were encountered: