Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
mobile_scanner
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Navaron Bracke
2022-12-11 20:28:31 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
12c5db10647eea7ddb4634819de0b503ab9e070c
12c5db10
1 parent
61febbbc
use error builder in example
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
12 deletions
example/lib/barcode_list_scanner_controller.dart
example/lib/barcode_scanner_controller.dart
example/lib/barcode_scanner_returning_image.dart
example/lib/barcode_scanner_without_controller.dart
example/lib/barcode_list_scanner_controller.dart
View file @
12c5db1
import
'package:flutter/material.dart'
;
import
'package:image_picker/image_picker.dart'
;
import
'package:mobile_scanner/mobile_scanner.dart'
;
import
'package:mobile_scanner_example/scanner_error_widget.dart'
;
class
BarcodeListScannerWithController
extends
StatefulWidget
{
const
BarcodeListScannerWithController
({
Key
?
key
})
:
super
(
key:
key
);
...
...
@@ -25,7 +26,6 @@ class _BarcodeListScannerWithControllerState
);
bool
isStarted
=
true
;
MobileScannerException
?
exception
;
void
_startOrStop
()
{
if
(
isStarted
)
{
...
...
@@ -33,9 +33,7 @@ class _BarcodeListScannerWithControllerState
}
else
{
controller
.
start
().
catchError
((
error
)
{
if
(
mounted
)
{
setState
(()
{
exception
=
error
as
MobileScannerException
;
});
setState
(()
{});
}
});
}
...
...
@@ -55,6 +53,9 @@ class _BarcodeListScannerWithControllerState
children:
[
MobileScanner
(
controller:
controller
,
errorBuilder:
(
context
,
error
,
child
)
{
return
ScannerErrorWidget
(
error:
error
);
},
fit:
BoxFit
.
contain
,
onDetect:
(
barcodeCapture
)
{
setState
(()
{
...
...
example/lib/barcode_scanner_controller.dart
View file @
12c5db1
import
'package:flutter/material.dart'
;
import
'package:image_picker/image_picker.dart'
;
import
'package:mobile_scanner/mobile_scanner.dart'
;
import
'package:mobile_scanner_example/scanner_error_widget.dart'
;
class
BarcodeScannerWithController
extends
StatefulWidget
{
const
BarcodeScannerWithController
({
Key
?
key
})
:
super
(
key:
key
);
...
...
@@ -25,7 +26,6 @@ class _BarcodeScannerWithControllerState
);
bool
isStarted
=
true
;
MobileScannerException
?
exception
;
void
_startOrStop
()
{
if
(
isStarted
)
{
...
...
@@ -33,9 +33,7 @@ class _BarcodeScannerWithControllerState
}
else
{
controller
.
start
().
catchError
((
error
)
{
if
(
mounted
)
{
setState
(()
{
exception
=
error
as
MobileScannerException
;
});
setState
(()
{});
}
});
}
...
...
@@ -55,6 +53,9 @@ class _BarcodeScannerWithControllerState
children:
[
MobileScanner
(
controller:
controller
,
errorBuilder:
(
context
,
error
,
child
)
{
return
ScannerErrorWidget
(
error:
error
);
},
fit:
BoxFit
.
contain
,
onDetect:
(
barcode
)
{
setState
(()
{
...
...
example/lib/barcode_scanner_returning_image.dart
View file @
12c5db1
...
...
@@ -2,6 +2,7 @@ import 'dart:math';
import
'package:flutter/material.dart'
;
import
'package:mobile_scanner/mobile_scanner.dart'
;
import
'package:mobile_scanner_example/scanner_error_widget.dart'
;
class
BarcodeScannerReturningImage
extends
StatefulWidget
{
const
BarcodeScannerReturningImage
({
Key
?
key
})
:
super
(
key:
key
);
...
...
@@ -27,7 +28,6 @@ class _BarcodeScannerReturningImageState
);
bool
isStarted
=
true
;
MobileScannerException
?
exception
;
void
_startOrStop
()
{
if
(
isStarted
)
{
...
...
@@ -35,9 +35,7 @@ class _BarcodeScannerReturningImageState
}
else
{
controller
.
start
().
catchError
((
error
)
{
if
(
mounted
)
{
setState
(()
{
exception
=
error
as
MobileScannerException
;
});
setState
(()
{});
}
});
}
...
...
@@ -77,6 +75,9 @@ class _BarcodeScannerReturningImageState
children:
[
MobileScanner
(
controller:
controller
,
errorBuilder:
(
context
,
error
,
child
)
{
return
ScannerErrorWidget
(
error:
error
);
},
fit:
BoxFit
.
contain
,
onDetect:
(
barcode
)
{
setState
(()
{
...
...
example/lib/barcode_scanner_without_controller.dart
View file @
12c5db1
import
'package:flutter/material.dart'
;
import
'package:mobile_scanner/mobile_scanner.dart'
;
import
'package:mobile_scanner_example/scanner_error_widget.dart'
;
class
BarcodeScannerWithoutController
extends
StatefulWidget
{
const
BarcodeScannerWithoutController
({
Key
?
key
})
:
super
(
key:
key
);
...
...
@@ -24,6 +25,9 @@ class _BarcodeScannerWithoutControllerState
children:
[
MobileScanner
(
fit:
BoxFit
.
contain
,
errorBuilder:
(
context
,
error
,
child
)
{
return
ScannerErrorWidget
(
error:
error
);
},
onDetect:
(
capture
)
{
setState
(()
{
this
.
capture
=
capture
;
...
...
Please
register
or
login
to post a comment