Remove torchState variable in ValueListenableBuilder

This commit is contained in:
r4khul 2026-02-04 20:24:10 +05:30
parent 79cc43da0d
commit fc640eade0

View file

@ -48,14 +48,13 @@ class _QrCodeScreenState extends State<QrCodeScreen> {
ValueListenableBuilder<MobileScannerState>( ValueListenableBuilder<MobileScannerState>(
valueListenable: _controller, valueListenable: _controller,
builder: (context, state, _) { builder: (context, state, _) {
final torchState = state.torchState;
return IconButton( return IconButton(
icon: Icon( icon: Icon(
torchState == TorchState.on state.torchState == TorchState.on
? Icons.flash_on ? Icons.flash_on
: Icons.flash_off, : Icons.flash_off,
), ),
onPressed: torchState == TorchState.unavailable onPressed: state.torchState == TorchState.unavailable
? null ? null
: () => _controller.toggleTorch(), : () => _controller.toggleTorch(),
); );