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
Julian Steenbakker
2022-11-17 11:33:08 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a0c60f5bcaf7c77a22fd30285c99a87a79580596
a0c60f5b
1 parent
d31d7c4a
style: flutter format
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
117 deletions
example/lib/barcode_scanner_returning_image.dart
example/lib/barcode_scanner_returning_image.dart
View file @
a0c60f5
...
...
@@ -34,140 +34,141 @@ class _BarcodeScannerReturningImageState
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
body:
SafeArea
(
child:
Column
(
children:
[
Expanded
(
child:
barcode
?.
image
!=
null
?
Transform
.
rotate
(
angle:
90
*
pi
/
180
,
child:
Image
(
gaplessPlayback:
true
,
image:
MemoryImage
(
barcode
!.
image
!),
fit:
BoxFit
.
contain
,
body:
SafeArea
(
child:
Column
(
children:
[
Expanded
(
child:
barcode
?.
image
!=
null
?
Transform
.
rotate
(
angle:
90
*
pi
/
180
,
child:
Image
(
gaplessPlayback:
true
,
image:
MemoryImage
(
barcode
!.
image
!),
fit:
BoxFit
.
contain
,
),
)
:
const
Center
(
child:
Text
(
'Your scanned barcode will appear here!'
,
),
),
)
:
const
Center
(
child:
Text
(
'Your scanned barcode will appear here!'
,
),
Expanded
(
flex:
2
,
child:
ColoredBox
(
color:
Colors
.
grey
,
child:
Stack
(
children:
[
MobileScanner
(
controller:
controller
,
fit:
BoxFit
.
contain
,
// controller: MobileScannerController(
// torchEnabled: true,
// facing: CameraFacing.front,
// ),
onDetect:
(
barcode
)
{
setState
(()
{
this
.
barcode
=
barcode
;
});
},
),
),
),
Expanded
(
flex:
2
,
child:
ColoredBox
(
color:
Colors
.
grey
,
child:
Stack
(
children:
[
MobileScanner
(
controller:
controller
,
fit:
BoxFit
.
contain
,
// controller: MobileScannerController(
// torchEnabled: true,
// facing: CameraFacing.front,
// ),
onDetect:
(
barcode
)
{
setState
(()
{
this
.
barcode
=
barcode
;
});
},
),
Align
(
alignment:
Alignment
.
bottomCenter
,
child:
Container
(
Align
(
alignment:
Alignment
.
bottomCenter
,
height:
100
,
color:
Colors
.
black
.
withOpacity
(
0.4
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
children:
[
IconButton
(
color:
Colors
.
white
,
icon:
ValueListenableBuilder
(
valueListenable:
controller
.
torchState
,
builder:
(
context
,
state
,
child
)
{
if
(
state
==
null
)
{
return
const
Icon
(
Icons
.
flash_off
,
color:
Colors
.
grey
,
);
}
switch
(
state
as
TorchState
)
{
case
TorchState
.
off
:
child:
Container
(
alignment:
Alignment
.
bottomCenter
,
height:
100
,
color:
Colors
.
black
.
withOpacity
(
0.4
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
children:
[
IconButton
(
color:
Colors
.
white
,
icon:
ValueListenableBuilder
(
valueListenable:
controller
.
torchState
,
builder:
(
context
,
state
,
child
)
{
if
(
state
==
null
)
{
return
const
Icon
(
Icons
.
flash_off
,
color:
Colors
.
grey
,
);
case
TorchState
.
on
:
return
const
Icon
(
Icons
.
flash_on
,
color:
Colors
.
yellow
,
);
}
},
}
switch
(
state
as
TorchState
)
{
case
TorchState
.
off
:
return
const
Icon
(
Icons
.
flash_off
,
color:
Colors
.
grey
,
);
case
TorchState
.
on
:
return
const
Icon
(
Icons
.
flash_on
,
color:
Colors
.
yellow
,
);
}
},
),
iconSize:
32.0
,
onPressed:
()
=>
controller
.
toggleTorch
(),
),
iconSize:
32.0
,
onPressed:
()
=>
controller
.
toggleTorch
(),
),
IconButton
(
color:
Colors
.
white
,
icon:
isStarted
?
const
Icon
(
Icons
.
stop
)
:
const
Icon
(
Icons
.
play_arrow
),
iconSize:
32.0
,
onPressed:
()
=>
setState
(()
{
isStarted
?
controller
.
stop
()
:
controller
.
start
();
isStarted
=
!
isStarted
;
}),
),
Center
(
child:
SizedBox
(
width:
MediaQuery
.
of
(
context
).
size
.
width
-
200
,
height:
50
,
child:
FittedBox
(
child:
Text
(
barcode
?.
barcodes
.
first
.
rawValue
??
'Scan something!'
,
overflow:
TextOverflow
.
fade
,
style:
Theme
.
of
(
context
)
.
textTheme
.
headline4
!
.
copyWith
(
color:
Colors
.
white
),
IconButton
(
color:
Colors
.
white
,
icon:
isStarted
?
const
Icon
(
Icons
.
stop
)
:
const
Icon
(
Icons
.
play_arrow
),
iconSize:
32.0
,
onPressed:
()
=>
setState
(()
{
isStarted
?
controller
.
stop
()
:
controller
.
start
();
isStarted
=
!
isStarted
;
}),
),
Center
(
child:
SizedBox
(
width:
MediaQuery
.
of
(
context
).
size
.
width
-
200
,
height:
50
,
child:
FittedBox
(
child:
Text
(
barcode
?.
barcodes
.
first
.
rawValue
??
'Scan something!'
,
overflow:
TextOverflow
.
fade
,
style:
Theme
.
of
(
context
)
.
textTheme
.
headline4
!
.
copyWith
(
color:
Colors
.
white
),
),
),
),
),
),
IconButton
(
color:
Colors
.
white
,
icon:
ValueListenableBuilder
(
valueListenable:
controller
.
cameraFacingState
,
builder:
(
context
,
state
,
child
)
{
if
(
state
==
null
)
{
return
const
Icon
(
Icons
.
camera_front
);
}
switch
(
state
as
CameraFacing
)
{
case
CameraFacing
.
front
:
IconButton
(
color:
Colors
.
white
,
icon:
ValueListenableBuilder
(
valueListenable:
controller
.
cameraFacingState
,
builder:
(
context
,
state
,
child
)
{
if
(
state
==
null
)
{
return
const
Icon
(
Icons
.
camera_front
);
case
CameraFacing
.
back
:
return
const
Icon
(
Icons
.
camera_rear
);
}
},
}
switch
(
state
as
CameraFacing
)
{
case
CameraFacing
.
front
:
return
const
Icon
(
Icons
.
camera_front
);
case
CameraFacing
.
back
:
return
const
Icon
(
Icons
.
camera_rear
);
}
},
),
iconSize:
32.0
,
onPressed:
()
=>
controller
.
switchCamera
(),
),
iconSize:
32.0
,
onPressed:
()
=>
controller
.
switchCamera
(),
),
],
],
),
),
),
),
],
],
),
),
),
),
],
],
),
),
)
,)
;
);
}
}
...
...
Please
register
or
login
to post a comment