Showing
2 changed files
with
0 additions
and
86 deletions
| 1 | -import 'package:flutter/material.dart'; | ||
| 2 | -import 'package:mobile_scanner/mobile_scanner.dart'; | ||
| 3 | -import 'package:mobile_scanner_example/scanner_error_widget.dart'; | ||
| 4 | - | ||
| 5 | -class BarcodeScannerWithoutController extends StatefulWidget { | ||
| 6 | - const BarcodeScannerWithoutController({super.key}); | ||
| 7 | - | ||
| 8 | - @override | ||
| 9 | - State<BarcodeScannerWithoutController> createState() => | ||
| 10 | - _BarcodeScannerWithoutControllerState(); | ||
| 11 | -} | ||
| 12 | - | ||
| 13 | -class _BarcodeScannerWithoutControllerState | ||
| 14 | - extends State<BarcodeScannerWithoutController> | ||
| 15 | - with SingleTickerProviderStateMixin { | ||
| 16 | - BarcodeCapture? capture; | ||
| 17 | - | ||
| 18 | - @override | ||
| 19 | - Widget build(BuildContext context) { | ||
| 20 | - return Scaffold( | ||
| 21 | - appBar: AppBar(title: const Text('Without controller')), | ||
| 22 | - backgroundColor: Colors.black, | ||
| 23 | - body: Builder( | ||
| 24 | - builder: (context) { | ||
| 25 | - return Stack( | ||
| 26 | - children: [ | ||
| 27 | - MobileScanner( | ||
| 28 | - fit: BoxFit.contain, | ||
| 29 | - errorBuilder: (context, error, child) { | ||
| 30 | - return ScannerErrorWidget(error: error); | ||
| 31 | - }, | ||
| 32 | - onDetect: (capture) { | ||
| 33 | - setState(() { | ||
| 34 | - this.capture = capture; | ||
| 35 | - }); | ||
| 36 | - }, | ||
| 37 | - ), | ||
| 38 | - Align( | ||
| 39 | - alignment: Alignment.bottomCenter, | ||
| 40 | - child: Container( | ||
| 41 | - alignment: Alignment.bottomCenter, | ||
| 42 | - height: 100, | ||
| 43 | - color: Colors.black.withOpacity(0.4), | ||
| 44 | - child: Row( | ||
| 45 | - mainAxisAlignment: MainAxisAlignment.spaceEvenly, | ||
| 46 | - children: [ | ||
| 47 | - Center( | ||
| 48 | - child: SizedBox( | ||
| 49 | - width: MediaQuery.of(context).size.width - 120, | ||
| 50 | - height: 50, | ||
| 51 | - child: FittedBox( | ||
| 52 | - child: Text( | ||
| 53 | - capture?.barcodes.first.rawValue ?? | ||
| 54 | - 'Scan something!', | ||
| 55 | - overflow: TextOverflow.fade, | ||
| 56 | - style: Theme.of(context) | ||
| 57 | - .textTheme | ||
| 58 | - .headlineMedium! | ||
| 59 | - .copyWith(color: Colors.white), | ||
| 60 | - ), | ||
| 61 | - ), | ||
| 62 | - ), | ||
| 63 | - ), | ||
| 64 | - ], | ||
| 65 | - ), | ||
| 66 | - ), | ||
| 67 | - ), | ||
| 68 | - ], | ||
| 69 | - ); | ||
| 70 | - }, | ||
| 71 | - ), | ||
| 72 | - ); | ||
| 73 | - } | ||
| 74 | -} |
| @@ -4,7 +4,6 @@ import 'package:mobile_scanner_example/barcode_scanner_controller.dart'; | @@ -4,7 +4,6 @@ import 'package:mobile_scanner_example/barcode_scanner_controller.dart'; | ||
| 4 | import 'package:mobile_scanner_example/barcode_scanner_pageview.dart'; | 4 | import 'package:mobile_scanner_example/barcode_scanner_pageview.dart'; |
| 5 | import 'package:mobile_scanner_example/barcode_scanner_returning_image.dart'; | 5 | import 'package:mobile_scanner_example/barcode_scanner_returning_image.dart'; |
| 6 | import 'package:mobile_scanner_example/barcode_scanner_window.dart'; | 6 | import 'package:mobile_scanner_example/barcode_scanner_window.dart'; |
| 7 | -import 'package:mobile_scanner_example/barcode_scanner_without_controller.dart'; | ||
| 8 | import 'package:mobile_scanner_example/barcode_scanner_zoom.dart'; | 7 | import 'package:mobile_scanner_example/barcode_scanner_zoom.dart'; |
| 9 | import 'package:mobile_scanner_example/mobile_scanner_overlay.dart'; | 8 | import 'package:mobile_scanner_example/mobile_scanner_overlay.dart'; |
| 10 | 9 | ||
| @@ -76,17 +75,6 @@ class MyHome extends StatelessWidget { | @@ -76,17 +75,6 @@ class MyHome extends StatelessWidget { | ||
| 76 | onPressed: () { | 75 | onPressed: () { |
| 77 | Navigator.of(context).push( | 76 | Navigator.of(context).push( |
| 78 | MaterialPageRoute( | 77 | MaterialPageRoute( |
| 79 | - builder: (context) => | ||
| 80 | - const BarcodeScannerWithoutController(), | ||
| 81 | - ), | ||
| 82 | - ); | ||
| 83 | - }, | ||
| 84 | - child: const Text('MobileScanner without Controller'), | ||
| 85 | - ), | ||
| 86 | - ElevatedButton( | ||
| 87 | - onPressed: () { | ||
| 88 | - Navigator.of(context).push( | ||
| 89 | - MaterialPageRoute( | ||
| 90 | builder: (context) => const BarcodeScannerWithZoom(), | 78 | builder: (context) => const BarcodeScannerWithZoom(), |
| 91 | ), | 79 | ), |
| 92 | ); | 80 | ); |
-
Please register or login to post a comment