Julian Steenbakker

style: flutter format

@@ -34,140 +34,141 @@ class _BarcodeScannerReturningImageState @@ -34,140 +34,141 @@ class _BarcodeScannerReturningImageState
34 @override 34 @override
35 Widget build(BuildContext context) { 35 Widget build(BuildContext context) {
36 return Scaffold( 36 return Scaffold(
37 - body: SafeArea(  
38 - child: Column(  
39 - children: [  
40 - Expanded(  
41 - child: barcode?.image != null  
42 - ? Transform.rotate(  
43 - angle: 90 * pi / 180,  
44 - child: Image(  
45 - gaplessPlayback: true,  
46 - image: MemoryImage(barcode!.image!),  
47 - fit: BoxFit.contain, 37 + body: SafeArea(
  38 + child: Column(
  39 + children: [
  40 + Expanded(
  41 + child: barcode?.image != null
  42 + ? Transform.rotate(
  43 + angle: 90 * pi / 180,
  44 + child: Image(
  45 + gaplessPlayback: true,
  46 + image: MemoryImage(barcode!.image!),
  47 + fit: BoxFit.contain,
  48 + ),
  49 + )
  50 + : const Center(
  51 + child: Text(
  52 + 'Your scanned barcode will appear here!',
  53 + ),
48 ), 54 ),
49 - )  
50 - : const Center(  
51 - child: Text(  
52 - 'Your scanned barcode will appear here!', 55 + ),
  56 + Expanded(
  57 + flex: 2,
  58 + child: ColoredBox(
  59 + color: Colors.grey,
  60 + child: Stack(
  61 + children: [
  62 + MobileScanner(
  63 + controller: controller,
  64 + fit: BoxFit.contain,
  65 + // controller: MobileScannerController(
  66 + // torchEnabled: true,
  67 + // facing: CameraFacing.front,
  68 + // ),
  69 + onDetect: (barcode) {
  70 + setState(() {
  71 + this.barcode = barcode;
  72 + });
  73 + },
53 ), 74 ),
54 - ),  
55 - ),  
56 - Expanded(  
57 - flex: 2,  
58 - child: ColoredBox(  
59 - color: Colors.grey,  
60 - child: Stack(  
61 - children: [  
62 - MobileScanner(  
63 - controller: controller,  
64 - fit: BoxFit.contain,  
65 - // controller: MobileScannerController(  
66 - // torchEnabled: true,  
67 - // facing: CameraFacing.front,  
68 - // ),  
69 - onDetect: (barcode) {  
70 - setState(() {  
71 - this.barcode = barcode;  
72 - });  
73 - },  
74 - ),  
75 - Align(  
76 - alignment: Alignment.bottomCenter,  
77 - child: Container( 75 + Align(
78 alignment: Alignment.bottomCenter, 76 alignment: Alignment.bottomCenter,
79 - height: 100,  
80 - color: Colors.black.withOpacity(0.4),  
81 - child: Row(  
82 - mainAxisAlignment: MainAxisAlignment.spaceEvenly,  
83 - children: [  
84 - IconButton(  
85 - color: Colors.white,  
86 - icon: ValueListenableBuilder(  
87 - valueListenable: controller.torchState,  
88 - builder: (context, state, child) {  
89 - if (state == null) {  
90 - return const Icon(  
91 - Icons.flash_off,  
92 - color: Colors.grey,  
93 - );  
94 - }  
95 - switch (state as TorchState) {  
96 - case TorchState.off: 77 + child: Container(
  78 + alignment: Alignment.bottomCenter,
  79 + height: 100,
  80 + color: Colors.black.withOpacity(0.4),
  81 + child: Row(
  82 + mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  83 + children: [
  84 + IconButton(
  85 + color: Colors.white,
  86 + icon: ValueListenableBuilder(
  87 + valueListenable: controller.torchState,
  88 + builder: (context, state, child) {
  89 + if (state == null) {
97 return const Icon( 90 return const Icon(
98 Icons.flash_off, 91 Icons.flash_off,
99 color: Colors.grey, 92 color: Colors.grey,
100 ); 93 );
101 - case TorchState.on:  
102 - return const Icon(  
103 - Icons.flash_on,  
104 - color: Colors.yellow,  
105 - );  
106 - }  
107 - }, 94 + }
  95 + switch (state as TorchState) {
  96 + case TorchState.off:
  97 + return const Icon(
  98 + Icons.flash_off,
  99 + color: Colors.grey,
  100 + );
  101 + case TorchState.on:
  102 + return const Icon(
  103 + Icons.flash_on,
  104 + color: Colors.yellow,
  105 + );
  106 + }
  107 + },
  108 + ),
  109 + iconSize: 32.0,
  110 + onPressed: () => controller.toggleTorch(),
108 ), 111 ),
109 - iconSize: 32.0,  
110 - onPressed: () => controller.toggleTorch(),  
111 - ),  
112 - IconButton(  
113 - color: Colors.white,  
114 - icon: isStarted  
115 - ? const Icon(Icons.stop)  
116 - : const Icon(Icons.play_arrow),  
117 - iconSize: 32.0,  
118 - onPressed: () => setState(() {  
119 - isStarted  
120 - ? controller.stop()  
121 - : controller.start();  
122 - isStarted = !isStarted;  
123 - }),  
124 - ),  
125 - Center(  
126 - child: SizedBox(  
127 - width: MediaQuery.of(context).size.width - 200,  
128 - height: 50,  
129 - child: FittedBox(  
130 - child: Text(  
131 - barcode?.barcodes.first.rawValue ??  
132 - 'Scan something!',  
133 - overflow: TextOverflow.fade,  
134 - style: Theme.of(context)  
135 - .textTheme  
136 - .headline4!  
137 - .copyWith(color: Colors.white), 112 + IconButton(
  113 + color: Colors.white,
  114 + icon: isStarted
  115 + ? const Icon(Icons.stop)
  116 + : const Icon(Icons.play_arrow),
  117 + iconSize: 32.0,
  118 + onPressed: () => setState(() {
  119 + isStarted
  120 + ? controller.stop()
  121 + : controller.start();
  122 + isStarted = !isStarted;
  123 + }),
  124 + ),
  125 + Center(
  126 + child: SizedBox(
  127 + width: MediaQuery.of(context).size.width - 200,
  128 + height: 50,
  129 + child: FittedBox(
  130 + child: Text(
  131 + barcode?.barcodes.first.rawValue ??
  132 + 'Scan something!',
  133 + overflow: TextOverflow.fade,
  134 + style: Theme.of(context)
  135 + .textTheme
  136 + .headline4!
  137 + .copyWith(color: Colors.white),
  138 + ),
138 ), 139 ),
139 ), 140 ),
140 ), 141 ),
141 - ),  
142 - IconButton(  
143 - color: Colors.white,  
144 - icon: ValueListenableBuilder(  
145 - valueListenable: controller.cameraFacingState,  
146 - builder: (context, state, child) {  
147 - if (state == null) {  
148 - return const Icon(Icons.camera_front);  
149 - }  
150 - switch (state as CameraFacing) {  
151 - case CameraFacing.front: 142 + IconButton(
  143 + color: Colors.white,
  144 + icon: ValueListenableBuilder(
  145 + valueListenable: controller.cameraFacingState,
  146 + builder: (context, state, child) {
  147 + if (state == null) {
152 return const Icon(Icons.camera_front); 148 return const Icon(Icons.camera_front);
153 - case CameraFacing.back:  
154 - return const Icon(Icons.camera_rear);  
155 - }  
156 - }, 149 + }
  150 + switch (state as CameraFacing) {
  151 + case CameraFacing.front:
  152 + return const Icon(Icons.camera_front);
  153 + case CameraFacing.back:
  154 + return const Icon(Icons.camera_rear);
  155 + }
  156 + },
  157 + ),
  158 + iconSize: 32.0,
  159 + onPressed: () => controller.switchCamera(),
157 ), 160 ),
158 - iconSize: 32.0,  
159 - onPressed: () => controller.switchCamera(),  
160 - ),  
161 - ], 161 + ],
  162 + ),
162 ), 163 ),
163 ), 164 ),
164 - ),  
165 - ], 165 + ],
  166 + ),
166 ), 167 ),
167 ), 168 ),
168 - ),  
169 - ], 169 + ],
  170 + ),
170 ), 171 ),
171 - ),); 172 + );
172 } 173 }
173 } 174 }