Showing
1 changed file
with
31 additions
and
30 deletions
| @@ -78,40 +78,41 @@ class _BarcodeScannerWithControllerState | @@ -78,40 +78,41 @@ class _BarcodeScannerWithControllerState | ||
| 78 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, | 78 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
| 79 | children: [ | 79 | children: [ |
| 80 | ValueListenableBuilder( | 80 | ValueListenableBuilder( |
| 81 | - valueListenable: controller.hasTorchState, | ||
| 82 | - builder: (context, state, child) { | ||
| 83 | - if (state != true) { | ||
| 84 | - return const SizedBox.shrink(); | ||
| 85 | - } | ||
| 86 | - return IconButton( | ||
| 87 | - color: Colors.white, | ||
| 88 | - icon: ValueListenableBuilder( | ||
| 89 | - valueListenable: controller.torchState, | ||
| 90 | - builder: (context, state, child) { | ||
| 91 | - if (state == null) { | 81 | + valueListenable: controller.hasTorchState, |
| 82 | + builder: (context, state, child) { | ||
| 83 | + if (state != true) { | ||
| 84 | + return const SizedBox.shrink(); | ||
| 85 | + } | ||
| 86 | + return IconButton( | ||
| 87 | + color: Colors.white, | ||
| 88 | + icon: ValueListenableBuilder( | ||
| 89 | + valueListenable: controller.torchState, | ||
| 90 | + builder: (context, state, child) { | ||
| 91 | + if (state == null) { | ||
| 92 | + return const Icon( | ||
| 93 | + Icons.flash_off, | ||
| 94 | + color: Colors.grey, | ||
| 95 | + ); | ||
| 96 | + } | ||
| 97 | + switch (state as TorchState) { | ||
| 98 | + case TorchState.off: | ||
| 92 | return const Icon( | 99 | return const Icon( |
| 93 | Icons.flash_off, | 100 | Icons.flash_off, |
| 94 | color: Colors.grey, | 101 | color: Colors.grey, |
| 95 | ); | 102 | ); |
| 96 | - } | ||
| 97 | - switch (state as TorchState) { | ||
| 98 | - case TorchState.off: | ||
| 99 | - return const Icon( | ||
| 100 | - Icons.flash_off, | ||
| 101 | - color: Colors.grey, | ||
| 102 | - ); | ||
| 103 | - case TorchState.on: | ||
| 104 | - return const Icon( | ||
| 105 | - Icons.flash_on, | ||
| 106 | - color: Colors.yellow, | ||
| 107 | - ); | ||
| 108 | - } | ||
| 109 | - }, | ||
| 110 | - ), | ||
| 111 | - iconSize: 32.0, | ||
| 112 | - onPressed: () => controller.toggleTorch(), | ||
| 113 | - ); | ||
| 114 | - }), | 103 | + case TorchState.on: |
| 104 | + return const Icon( | ||
| 105 | + Icons.flash_on, | ||
| 106 | + color: Colors.yellow, | ||
| 107 | + ); | ||
| 108 | + } | ||
| 109 | + }, | ||
| 110 | + ), | ||
| 111 | + iconSize: 32.0, | ||
| 112 | + onPressed: () => controller.toggleTorch(), | ||
| 113 | + ); | ||
| 114 | + }, | ||
| 115 | + ), | ||
| 115 | IconButton( | 116 | IconButton( |
| 116 | color: Colors.white, | 117 | color: Colors.white, |
| 117 | icon: isStarted | 118 | icon: isStarted |
-
Please register or login to post a comment