Skip to content

Commit

Permalink
Fix breaking changes for mobile_scanner 5.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Pabon committed Aug 29, 2024
1 parent 7194cb1 commit 1e92ac9
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions lib/app/pages/qr_scanner_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ class _QRScannerState extends State<QRScanner> with AppLogger {
IconButton(
color: Theme.of(context).primaryColorDark,
icon: ValueListenableBuilder(
valueListenable: cameraController.torchState,
builder: (context, state, child) {
switch (state) {
case TorchState.off:
return const Icon(Icons.flash_off, color: Colors.grey);
case TorchState.on:
return Icon(Icons.flash_on, color: Colors.yellow[800]);
}
valueListenable: cameraController,
builder: (context, state, child) => switch (state.torchState) {
TorchState.off =>
const Icon(Icons.flash_off_outlined, color: Colors.grey),
TorchState.on =>
Icon(Icons.flash_on_outlined, color: Colors.yellow[800]),
TorchState.auto =>
const Icon(Icons.flash_auto_outlined, color: Colors.grey),
TorchState.unavailable =>
const Icon(Icons.flash_off_outlined, color: Colors.white54),
},
),
iconSize: Dimensions.sizeIconAverage,
Expand All @@ -46,14 +48,11 @@ class _QRScannerState extends State<QRScanner> with AppLogger {
IconButton(
color: Theme.of(context).primaryColorDark,
icon: ValueListenableBuilder(
valueListenable: cameraController.cameraFacingState,
builder: (context, state, child) {
switch (state) {
case CameraFacing.front:
return const Icon(Icons.camera_front);
case CameraFacing.back:
return const Icon(Icons.camera_rear);
}
valueListenable: cameraController,
builder: (context, state, child) =>
switch (state.cameraDirection) {
CameraFacing.front => const Icon(Icons.camera_front),
CameraFacing.back => const Icon(Icons.camera_rear),
},
),
iconSize: Dimensions.sizeIconAverage,
Expand All @@ -71,8 +70,8 @@ class _QRScannerState extends State<QRScanner> with AppLogger {
controller: cameraController,
onDetect: (capture) async {
String? code;
if (capture.raw.isNotEmpty) {
code = capture.raw[0]['rawValue'];
if ((capture.raw as List?)?.isNotEmpty ?? false) {
code = (capture.raw as List?)?[0]['rawValue'];
}

if (code == null) {
Expand Down

0 comments on commit 1e92ac9

Please sign in to comment.