Julian Steenbakker
Committed by GitHub

Merge pull request #467 from juliansteenbakker/imp/upgrade-flutter

imp: refactor code to latest stable flutter release
@@ -28,19 +28,23 @@ class _BarcodeListScannerWithControllerState @@ -28,19 +28,23 @@ class _BarcodeListScannerWithControllerState
28 bool isStarted = true; 28 bool isStarted = true;
29 29
30 void _startOrStop() { 30 void _startOrStop() {
  31 + try {
31 if (isStarted) { 32 if (isStarted) {
32 controller.stop(); 33 controller.stop();
33 } else { 34 } else {
34 - controller.start().catchError((error) {  
35 - if (mounted) {  
36 - setState(() {}); 35 + controller.start();
37 } 36 }
38 - });  
39 - }  
40 -  
41 setState(() { 37 setState(() {
42 isStarted = !isStarted; 38 isStarted = !isStarted;
43 }); 39 });
  40 + } on Exception catch (e) {
  41 + ScaffoldMessenger.of(context).showSnackBar(
  42 + SnackBar(
  43 + content: Text('Something went wrong! $e'),
  44 + backgroundColor: Colors.red,
  45 + ),
  46 + );
  47 + }
44 } 48 }
45 49
46 @override 50 @override
@@ -121,7 +125,7 @@ class _BarcodeListScannerWithControllerState @@ -121,7 +125,7 @@ class _BarcodeListScannerWithControllerState
121 overflow: TextOverflow.fade, 125 overflow: TextOverflow.fade,
122 style: Theme.of(context) 126 style: Theme.of(context)
123 .textTheme 127 .textTheme
124 - .headline4! 128 + .headlineMedium!
125 .copyWith(color: Colors.white), 129 .copyWith(color: Colors.white),
126 ), 130 ),
127 ), 131 ),
@@ -28,19 +28,23 @@ class _BarcodeScannerWithControllerState @@ -28,19 +28,23 @@ class _BarcodeScannerWithControllerState
28 bool isStarted = true; 28 bool isStarted = true;
29 29
30 void _startOrStop() { 30 void _startOrStop() {
  31 + try {
31 if (isStarted) { 32 if (isStarted) {
32 controller.stop(); 33 controller.stop();
33 } else { 34 } else {
34 - controller.start().catchError((error) {  
35 - if (mounted) {  
36 - setState(() {}); 35 + controller.start();
37 } 36 }
38 - });  
39 - }  
40 -  
41 setState(() { 37 setState(() {
42 isStarted = !isStarted; 38 isStarted = !isStarted;
43 }); 39 });
  40 + } on Exception catch (e) {
  41 + ScaffoldMessenger.of(context).showSnackBar(
  42 + SnackBar(
  43 + content: Text('Something went wrong! $e'),
  44 + backgroundColor: Colors.red,
  45 + ),
  46 + );
  47 + }
44 } 48 }
45 49
46 @override 50 @override
@@ -127,7 +131,7 @@ class _BarcodeScannerWithControllerState @@ -127,7 +131,7 @@ class _BarcodeScannerWithControllerState
127 overflow: TextOverflow.fade, 131 overflow: TextOverflow.fade,
128 style: Theme.of(context) 132 style: Theme.of(context)
129 .textTheme 133 .textTheme
130 - .headline4! 134 + .headlineMedium!
131 .copyWith(color: Colors.white), 135 .copyWith(color: Colors.white),
132 ), 136 ),
133 ), 137 ),
@@ -30,19 +30,23 @@ class _BarcodeScannerReturningImageState @@ -30,19 +30,23 @@ class _BarcodeScannerReturningImageState
30 bool isStarted = true; 30 bool isStarted = true;
31 31
32 void _startOrStop() { 32 void _startOrStop() {
  33 + try {
33 if (isStarted) { 34 if (isStarted) {
34 controller.stop(); 35 controller.stop();
35 } else { 36 } else {
36 - controller.start().catchError((error) {  
37 - if (mounted) {  
38 - setState(() {}); 37 + controller.start();
39 } 38 }
40 - });  
41 - }  
42 -  
43 setState(() { 39 setState(() {
44 isStarted = !isStarted; 40 isStarted = !isStarted;
45 }); 41 });
  42 + } on Exception catch (e) {
  43 + ScaffoldMessenger.of(context).showSnackBar(
  44 + SnackBar(
  45 + content: Text('Something went wrong! $e'),
  46 + backgroundColor: Colors.red,
  47 + ),
  48 + );
  49 + }
46 } 50 }
47 51
48 @override 52 @override
@@ -141,7 +145,7 @@ class _BarcodeScannerReturningImageState @@ -141,7 +145,7 @@ class _BarcodeScannerReturningImageState
141 overflow: TextOverflow.fade, 145 overflow: TextOverflow.fade,
142 style: Theme.of(context) 146 style: Theme.of(context)
143 .textTheme 147 .textTheme
144 - .headline4! 148 + .headlineMedium!
145 .copyWith(color: Colors.white), 149 .copyWith(color: Colors.white),
146 ), 150 ),
147 ), 151 ),
@@ -82,7 +82,7 @@ class _BarcodeScannerWithScanWindowState @@ -82,7 +82,7 @@ class _BarcodeScannerWithScanWindowState
82 overflow: TextOverflow.fade, 82 overflow: TextOverflow.fade,
83 style: Theme.of(context) 83 style: Theme.of(context)
84 .textTheme 84 .textTheme
85 - .headline4! 85 + .headlineMedium!
86 .copyWith(color: Colors.white), 86 .copyWith(color: Colors.white),
87 ), 87 ),
88 ), 88 ),
@@ -54,7 +54,7 @@ class _BarcodeScannerWithoutControllerState @@ -54,7 +54,7 @@ class _BarcodeScannerWithoutControllerState
54 overflow: TextOverflow.fade, 54 overflow: TextOverflow.fade,
55 style: Theme.of(context) 55 style: Theme.of(context)
56 .textTheme 56 .textTheme
57 - .headline4! 57 + .headlineMedium!
58 .copyWith(color: Colors.white), 58 .copyWith(color: Colors.white),
59 ), 59 ),
60 ), 60 ),
@@ -109,7 +109,7 @@ class _BarcodeScannerWithZoomState extends State<BarcodeScannerWithZoom> @@ -109,7 +109,7 @@ class _BarcodeScannerWithZoomState extends State<BarcodeScannerWithZoom>
109 overflow: TextOverflow.fade, 109 overflow: TextOverflow.fade,
110 style: Theme.of(context) 110 style: Theme.of(context)
111 .textTheme 111 .textTheme
112 - .headline4! 112 + .headlineMedium!
113 .copyWith(color: Colors.white), 113 .copyWith(color: Colors.white),
114 ), 114 ),
115 ), 115 ),