add back buttons to pages; fix error builder for window page & zoom slider page
Showing
7 changed files
with
17 additions
and
0 deletions
| @@ -50,6 +50,7 @@ class _BarcodeListScannerWithControllerState | @@ -50,6 +50,7 @@ class _BarcodeListScannerWithControllerState | ||
| 50 | @override | 50 | @override |
| 51 | Widget build(BuildContext context) { | 51 | Widget build(BuildContext context) { |
| 52 | return Scaffold( | 52 | return Scaffold( |
| 53 | + appBar: AppBar(title: const Text('With ValueListenableBuilder')), | ||
| 53 | backgroundColor: Colors.black, | 54 | backgroundColor: Colors.black, |
| 54 | body: Builder( | 55 | body: Builder( |
| 55 | builder: (context) { | 56 | builder: (context) { |
| @@ -50,6 +50,7 @@ class _BarcodeScannerWithControllerState | @@ -50,6 +50,7 @@ class _BarcodeScannerWithControllerState | ||
| 50 | @override | 50 | @override |
| 51 | Widget build(BuildContext context) { | 51 | Widget build(BuildContext context) { |
| 52 | return Scaffold( | 52 | return Scaffold( |
| 53 | + appBar: AppBar(title: const Text('With controller')), | ||
| 53 | backgroundColor: Colors.black, | 54 | backgroundColor: Colors.black, |
| 54 | body: Builder( | 55 | body: Builder( |
| 55 | builder: (context) { | 56 | builder: (context) { |
| @@ -70,6 +70,7 @@ class _BarcodeScannerPageViewState extends State<BarcodeScannerPageView> | @@ -70,6 +70,7 @@ class _BarcodeScannerPageViewState extends State<BarcodeScannerPageView> | ||
| 70 | @override | 70 | @override |
| 71 | Widget build(BuildContext context) { | 71 | Widget build(BuildContext context) { |
| 72 | return Scaffold( | 72 | return Scaffold( |
| 73 | + appBar: AppBar(title: const Text('With PageView')), | ||
| 73 | backgroundColor: Colors.black, | 74 | backgroundColor: Colors.black, |
| 74 | body: PageView( | 75 | body: PageView( |
| 75 | children: [ | 76 | children: [ |
| @@ -52,6 +52,7 @@ class _BarcodeScannerReturningImageState | @@ -52,6 +52,7 @@ class _BarcodeScannerReturningImageState | ||
| 52 | @override | 52 | @override |
| 53 | Widget build(BuildContext context) { | 53 | Widget build(BuildContext context) { |
| 54 | return Scaffold( | 54 | return Scaffold( |
| 55 | + appBar: AppBar(title: const Text('Returning image')), | ||
| 55 | body: SafeArea( | 56 | body: SafeArea( |
| 56 | child: Column( | 57 | child: Column( |
| 57 | children: [ | 58 | children: [ |
| @@ -3,6 +3,8 @@ import 'dart:io'; | @@ -3,6 +3,8 @@ import 'dart:io'; | ||
| 3 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
| 4 | import 'package:mobile_scanner/mobile_scanner.dart'; | 4 | import 'package:mobile_scanner/mobile_scanner.dart'; |
| 5 | 5 | ||
| 6 | +import 'package:mobile_scanner_example/scanner_error_widget.dart'; | ||
| 7 | + | ||
| 6 | class BarcodeScannerWithScanWindow extends StatefulWidget { | 8 | class BarcodeScannerWithScanWindow extends StatefulWidget { |
| 7 | const BarcodeScannerWithScanWindow({Key? key}) : super(key: key); | 9 | const BarcodeScannerWithScanWindow({Key? key}) : super(key: key); |
| 8 | 10 | ||
| @@ -32,6 +34,7 @@ class _BarcodeScannerWithScanWindowState | @@ -32,6 +34,7 @@ class _BarcodeScannerWithScanWindowState | ||
| 32 | height: 200, | 34 | height: 200, |
| 33 | ); | 35 | ); |
| 34 | return Scaffold( | 36 | return Scaffold( |
| 37 | + appBar: AppBar(title: const Text('With Scan window')), | ||
| 35 | backgroundColor: Colors.black, | 38 | backgroundColor: Colors.black, |
| 36 | body: Builder( | 39 | body: Builder( |
| 37 | builder: (context) { | 40 | builder: (context) { |
| @@ -47,6 +50,9 @@ class _BarcodeScannerWithScanWindowState | @@ -47,6 +50,9 @@ class _BarcodeScannerWithScanWindowState | ||
| 47 | this.arguments = arguments; | 50 | this.arguments = arguments; |
| 48 | }); | 51 | }); |
| 49 | }, | 52 | }, |
| 53 | + errorBuilder: (context, error, child) { | ||
| 54 | + return ScannerErrorWidget(error: error); | ||
| 55 | + }, | ||
| 50 | onDetect: onDetect, | 56 | onDetect: onDetect, |
| 51 | ), | 57 | ), |
| 52 | if (barcode != null && | 58 | if (barcode != null && |
| @@ -18,6 +18,7 @@ class _BarcodeScannerWithoutControllerState | @@ -18,6 +18,7 @@ class _BarcodeScannerWithoutControllerState | ||
| 18 | @override | 18 | @override |
| 19 | Widget build(BuildContext context) { | 19 | Widget build(BuildContext context) { |
| 20 | return Scaffold( | 20 | return Scaffold( |
| 21 | + appBar: AppBar(title: const Text('Without controller')), | ||
| 21 | backgroundColor: Colors.black, | 22 | backgroundColor: Colors.black, |
| 22 | body: Builder( | 23 | body: Builder( |
| 23 | builder: (context) { | 24 | builder: (context) { |
| @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; | @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; | ||
| 2 | import 'package:image_picker/image_picker.dart'; | 2 | import 'package:image_picker/image_picker.dart'; |
| 3 | import 'package:mobile_scanner/mobile_scanner.dart'; | 3 | import 'package:mobile_scanner/mobile_scanner.dart'; |
| 4 | 4 | ||
| 5 | +import 'package:mobile_scanner_example/scanner_error_widget.dart'; | ||
| 6 | + | ||
| 5 | class BarcodeScannerWithZoom extends StatefulWidget { | 7 | class BarcodeScannerWithZoom extends StatefulWidget { |
| 6 | const BarcodeScannerWithZoom({Key? key}) : super(key: key); | 8 | const BarcodeScannerWithZoom({Key? key}) : super(key: key); |
| 7 | 9 | ||
| @@ -23,6 +25,7 @@ class _BarcodeScannerWithZoomState extends State<BarcodeScannerWithZoom> | @@ -23,6 +25,7 @@ class _BarcodeScannerWithZoomState extends State<BarcodeScannerWithZoom> | ||
| 23 | @override | 25 | @override |
| 24 | Widget build(BuildContext context) { | 26 | Widget build(BuildContext context) { |
| 25 | return Scaffold( | 27 | return Scaffold( |
| 28 | + appBar: AppBar(title: const Text('With zoom slider')), | ||
| 26 | backgroundColor: Colors.black, | 29 | backgroundColor: Colors.black, |
| 27 | body: Builder( | 30 | body: Builder( |
| 28 | builder: (context) { | 31 | builder: (context) { |
| @@ -31,6 +34,9 @@ class _BarcodeScannerWithZoomState extends State<BarcodeScannerWithZoom> | @@ -31,6 +34,9 @@ class _BarcodeScannerWithZoomState extends State<BarcodeScannerWithZoom> | ||
| 31 | MobileScanner( | 34 | MobileScanner( |
| 32 | controller: controller, | 35 | controller: controller, |
| 33 | fit: BoxFit.contain, | 36 | fit: BoxFit.contain, |
| 37 | + errorBuilder: (context, error, child) { | ||
| 38 | + return ScannerErrorWidget(error: error); | ||
| 39 | + }, | ||
| 34 | onDetect: (barcode) { | 40 | onDetect: (barcode) { |
| 35 | setState(() { | 41 | setState(() { |
| 36 | this.barcode = barcode; | 42 | this.barcode = barcode; |
-
Please register or login to post a comment