fix redundant cast; bump example to Dart 2.18 so that the check is reported as well
Showing
5 changed files
with
17 additions
and
53 deletions
| @@ -82,16 +82,10 @@ class _BarcodeListScannerWithControllerState | @@ -82,16 +82,10 @@ class _BarcodeListScannerWithControllerState | ||
| 82 | children: [ | 82 | children: [ |
| 83 | IconButton( | 83 | IconButton( |
| 84 | color: Colors.white, | 84 | color: Colors.white, |
| 85 | - icon: ValueListenableBuilder( | 85 | + icon: ValueListenableBuilder<TorchState>( |
| 86 | valueListenable: controller.torchState, | 86 | valueListenable: controller.torchState, |
| 87 | builder: (context, state, child) { | 87 | builder: (context, state, child) { |
| 88 | - if (state == null) { | ||
| 89 | - return const Icon( | ||
| 90 | - Icons.flash_off, | ||
| 91 | - color: Colors.grey, | ||
| 92 | - ); | ||
| 93 | - } | ||
| 94 | - switch (state as TorchState) { | 88 | + switch (state) { |
| 95 | case TorchState.off: | 89 | case TorchState.off: |
| 96 | return const Icon( | 90 | return const Icon( |
| 97 | Icons.flash_off, | 91 | Icons.flash_off, |
| @@ -134,13 +128,10 @@ class _BarcodeListScannerWithControllerState | @@ -134,13 +128,10 @@ class _BarcodeListScannerWithControllerState | ||
| 134 | ), | 128 | ), |
| 135 | IconButton( | 129 | IconButton( |
| 136 | color: Colors.white, | 130 | color: Colors.white, |
| 137 | - icon: ValueListenableBuilder( | 131 | + icon: ValueListenableBuilder<CameraFacing>( |
| 138 | valueListenable: controller.cameraFacingState, | 132 | valueListenable: controller.cameraFacingState, |
| 139 | builder: (context, state, child) { | 133 | builder: (context, state, child) { |
| 140 | - if (state == null) { | ||
| 141 | - return const Icon(Icons.camera_front); | ||
| 142 | - } | ||
| 143 | - switch (state as CameraFacing) { | 134 | + switch (state) { |
| 144 | case CameraFacing.front: | 135 | case CameraFacing.front: |
| 145 | return const Icon(Icons.camera_front); | 136 | return const Icon(Icons.camera_front); |
| 146 | case CameraFacing.back: | 137 | case CameraFacing.back: |
| @@ -85,16 +85,10 @@ class _BarcodeScannerWithControllerState | @@ -85,16 +85,10 @@ class _BarcodeScannerWithControllerState | ||
| 85 | } | 85 | } |
| 86 | return IconButton( | 86 | return IconButton( |
| 87 | color: Colors.white, | 87 | color: Colors.white, |
| 88 | - icon: ValueListenableBuilder( | 88 | + icon: ValueListenableBuilder<TorchState>( |
| 89 | valueListenable: controller.torchState, | 89 | valueListenable: controller.torchState, |
| 90 | builder: (context, state, child) { | 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) { | 91 | + switch (state) { |
| 98 | case TorchState.off: | 92 | case TorchState.off: |
| 99 | return const Icon( | 93 | return const Icon( |
| 100 | Icons.flash_off, | 94 | Icons.flash_off, |
| @@ -140,13 +134,10 @@ class _BarcodeScannerWithControllerState | @@ -140,13 +134,10 @@ class _BarcodeScannerWithControllerState | ||
| 140 | ), | 134 | ), |
| 141 | IconButton( | 135 | IconButton( |
| 142 | color: Colors.white, | 136 | color: Colors.white, |
| 143 | - icon: ValueListenableBuilder( | 137 | + icon: ValueListenableBuilder<CameraFacing>( |
| 144 | valueListenable: controller.cameraFacingState, | 138 | valueListenable: controller.cameraFacingState, |
| 145 | builder: (context, state, child) { | 139 | builder: (context, state, child) { |
| 146 | - if (state == null) { | ||
| 147 | - return const Icon(Icons.camera_front); | ||
| 148 | - } | ||
| 149 | - switch (state as CameraFacing) { | 140 | + switch (state) { |
| 150 | case CameraFacing.front: | 141 | case CameraFacing.front: |
| 151 | return const Icon(Icons.camera_front); | 142 | return const Icon(Icons.camera_front); |
| 152 | case CameraFacing.back: | 143 | case CameraFacing.back: |
| @@ -101,16 +101,10 @@ class _BarcodeScannerReturningImageState | @@ -101,16 +101,10 @@ class _BarcodeScannerReturningImageState | ||
| 101 | children: [ | 101 | children: [ |
| 102 | IconButton( | 102 | IconButton( |
| 103 | color: Colors.white, | 103 | color: Colors.white, |
| 104 | - icon: ValueListenableBuilder( | 104 | + icon: ValueListenableBuilder<TorchState>( |
| 105 | valueListenable: controller.torchState, | 105 | valueListenable: controller.torchState, |
| 106 | builder: (context, state, child) { | 106 | builder: (context, state, child) { |
| 107 | - if (state == null) { | ||
| 108 | - return const Icon( | ||
| 109 | - Icons.flash_off, | ||
| 110 | - color: Colors.grey, | ||
| 111 | - ); | ||
| 112 | - } | ||
| 113 | - switch (state as TorchState) { | 107 | + switch (state) { |
| 114 | case TorchState.off: | 108 | case TorchState.off: |
| 115 | return const Icon( | 109 | return const Icon( |
| 116 | Icons.flash_off, | 110 | Icons.flash_off, |
| @@ -154,13 +148,10 @@ class _BarcodeScannerReturningImageState | @@ -154,13 +148,10 @@ class _BarcodeScannerReturningImageState | ||
| 154 | ), | 148 | ), |
| 155 | IconButton( | 149 | IconButton( |
| 156 | color: Colors.white, | 150 | color: Colors.white, |
| 157 | - icon: ValueListenableBuilder( | 151 | + icon: ValueListenableBuilder<CameraFacing>( |
| 158 | valueListenable: controller.cameraFacingState, | 152 | valueListenable: controller.cameraFacingState, |
| 159 | builder: (context, state, child) { | 153 | builder: (context, state, child) { |
| 160 | - if (state == null) { | ||
| 161 | - return const Icon(Icons.camera_front); | ||
| 162 | - } | ||
| 163 | - switch (state as CameraFacing) { | 154 | + switch (state) { |
| 164 | case CameraFacing.front: | 155 | case CameraFacing.front: |
| 165 | return const Icon(Icons.camera_front); | 156 | return const Icon(Icons.camera_front); |
| 166 | case CameraFacing.back: | 157 | case CameraFacing.back: |
| @@ -65,16 +65,10 @@ class _BarcodeScannerWithZoomState extends State<BarcodeScannerWithZoom> | @@ -65,16 +65,10 @@ class _BarcodeScannerWithZoomState extends State<BarcodeScannerWithZoom> | ||
| 65 | children: [ | 65 | children: [ |
| 66 | IconButton( | 66 | IconButton( |
| 67 | color: Colors.white, | 67 | color: Colors.white, |
| 68 | - icon: ValueListenableBuilder( | 68 | + icon: ValueListenableBuilder<TorchState>( |
| 69 | valueListenable: controller.torchState, | 69 | valueListenable: controller.torchState, |
| 70 | builder: (context, state, child) { | 70 | builder: (context, state, child) { |
| 71 | - if (state == null) { | ||
| 72 | - return const Icon( | ||
| 73 | - Icons.flash_off, | ||
| 74 | - color: Colors.grey, | ||
| 75 | - ); | ||
| 76 | - } | ||
| 77 | - switch (state as TorchState) { | 71 | + switch (state) { |
| 78 | case TorchState.off: | 72 | case TorchState.off: |
| 79 | return const Icon( | 73 | return const Icon( |
| 80 | Icons.flash_off, | 74 | Icons.flash_off, |
| @@ -123,13 +117,10 @@ class _BarcodeScannerWithZoomState extends State<BarcodeScannerWithZoom> | @@ -123,13 +117,10 @@ class _BarcodeScannerWithZoomState extends State<BarcodeScannerWithZoom> | ||
| 123 | ), | 117 | ), |
| 124 | IconButton( | 118 | IconButton( |
| 125 | color: Colors.white, | 119 | color: Colors.white, |
| 126 | - icon: ValueListenableBuilder( | 120 | + icon: ValueListenableBuilder<CameraFacing>( |
| 127 | valueListenable: controller.cameraFacingState, | 121 | valueListenable: controller.cameraFacingState, |
| 128 | builder: (context, state, child) { | 122 | builder: (context, state, child) { |
| 129 | - if (state == null) { | ||
| 130 | - return const Icon(Icons.camera_front); | ||
| 131 | - } | ||
| 132 | - switch (state as CameraFacing) { | 123 | + switch (state) { |
| 133 | case CameraFacing.front: | 124 | case CameraFacing.front: |
| 134 | return const Icon(Icons.camera_front); | 125 | return const Icon(Icons.camera_front); |
| 135 | case CameraFacing.back: | 126 | case CameraFacing.back: |
| @@ -6,7 +6,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev | @@ -6,7 +6,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev | ||
| 6 | version: 0.0.1 | 6 | version: 0.0.1 |
| 7 | 7 | ||
| 8 | environment: | 8 | environment: |
| 9 | - sdk: '>=2.17.0 <4.0.0' | 9 | + sdk: '>=2.18.0 <4.0.0' |
| 10 | 10 | ||
| 11 | # Dependencies specify other packages that your package needs in order to work. | 11 | # Dependencies specify other packages that your package needs in order to work. |
| 12 | # To automatically upgrade your package dependencies to the latest versions | 12 | # To automatically upgrade your package dependencies to the latest versions |
-
Please register or login to post a comment