Showing
1 changed file
with
15 additions
and
1 deletions
| @@ -19,6 +19,8 @@ class _BarcodeScannerWithControllerState | @@ -19,6 +19,8 @@ class _BarcodeScannerWithControllerState | ||
| 19 | // facing: CameraFacing.front, | 19 | // facing: CameraFacing.front, |
| 20 | ); | 20 | ); |
| 21 | 21 | ||
| 22 | + bool isStarted = true; | ||
| 23 | + | ||
| 22 | @override | 24 | @override |
| 23 | Widget build(BuildContext context) { | 25 | Widget build(BuildContext context) { |
| 24 | return MaterialApp( | 26 | return MaterialApp( |
| @@ -69,9 +71,21 @@ class _BarcodeScannerWithControllerState | @@ -69,9 +71,21 @@ class _BarcodeScannerWithControllerState | ||
| 69 | iconSize: 32.0, | 71 | iconSize: 32.0, |
| 70 | onPressed: () => controller.toggleTorch(), | 72 | onPressed: () => controller.toggleTorch(), |
| 71 | ), | 73 | ), |
| 74 | + IconButton( | ||
| 75 | + color: Colors.white, | ||
| 76 | + icon: isStarted | ||
| 77 | + ? const Icon(Icons.stop) | ||
| 78 | + : const Icon(Icons.play_arrow), | ||
| 79 | + iconSize: 32.0, | ||
| 80 | + onPressed: () => setState(() { | ||
| 81 | + isStarted | ||
| 82 | + ? controller.stop() | ||
| 83 | + : controller.start(); | ||
| 84 | + isStarted = !isStarted; | ||
| 85 | + })), | ||
| 72 | Center( | 86 | Center( |
| 73 | child: SizedBox( | 87 | child: SizedBox( |
| 74 | - width: MediaQuery.of(context).size.width - 120, | 88 | + width: MediaQuery.of(context).size.width - 160, |
| 75 | height: 50, | 89 | height: 50, |
| 76 | child: FittedBox( | 90 | child: FittedBox( |
| 77 | child: Text( | 91 | child: Text( |
-
Please register or login to post a comment