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