Skip to content

Commit b813cf9

Browse files
committed
[camera_avfoundation] Format example main.dart
Formats the `main.dart` file in the example application to align with current project standards. This change primarily involves code formatting and does not alter any functionality.
1 parent fe84be7 commit b813cf9

File tree

1 file changed

+29
-87
lines changed
  • packages/camera/camera_avfoundation/example/lib

1 file changed

+29
-87
lines changed

packages/camera/camera_avfoundation/example/lib/main.dart

Lines changed: 29 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
138138
decoration: BoxDecoration(
139139
color: Colors.black,
140140
border: Border.all(
141-
color:
142-
controller != null && controller!.value.isRecordingVideo
141+
color: controller != null && controller!.value.isRecordingVideo
143142
? Colors.redAccent
144143
: Colors.grey,
145144
width: 3.0,
@@ -155,9 +154,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
155154
_modeControlRowWidget(),
156155
Padding(
157156
padding: const EdgeInsets.all(5.0),
158-
child: Row(
159-
children: <Widget>[_cameraTogglesRowWidget(), _thumbnailWidget()],
160-
),
157+
child: Row(children: <Widget>[_cameraTogglesRowWidget(), _thumbnailWidget()]),
161158
),
162159
],
163160
),
@@ -171,11 +168,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
171168
if (cameraController == null || !cameraController.value.isInitialized) {
172169
return const Text(
173170
'Tap a camera',
174-
style: TextStyle(
175-
color: Colors.white,
176-
fontSize: 24.0,
177-
fontWeight: FontWeight.w900,
178-
),
171+
style: TextStyle(color: Colors.white, fontSize: 24.0, fontWeight: FontWeight.w900),
179172
);
180173
} else {
181174
return Listener(
@@ -189,8 +182,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
189182
behavior: HitTestBehavior.opaque,
190183
onScaleStart: _handleScaleStart,
191184
onScaleUpdate: _handleScaleUpdate,
192-
onTapDown: (TapDownDetails details) =>
193-
onViewFinderTap(details, constraints),
185+
onTapDown: (TapDownDetails details) => onViewFinderTap(details, constraints),
194186
);
195187
},
196188
),
@@ -209,15 +201,9 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
209201
return;
210202
}
211203

212-
_currentScale = (_baseScale * details.scale).clamp(
213-
_minAvailableZoom,
214-
_maxAvailableZoom,
215-
);
204+
_currentScale = (_baseScale * details.scale).clamp(_minAvailableZoom, _maxAvailableZoom);
216205

217-
await CameraPlatform.instance.setZoomLevel(
218-
controller!.cameraId,
219-
_currentScale,
220-
);
206+
await CameraPlatform.instance.setZoomLevel(controller!.cameraId, _currentScale);
221207
}
222208

223209
/// Display the thumbnail of the captured image or video.
@@ -242,13 +228,9 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
242228
// pointing to a location within the browser. It may be displayed
243229
// either with Image.network or Image.memory after loading the image
244230
// bytes to memory.
245-
kIsWeb
246-
? Image.network(imageFile!.path)
247-
: Image.file(File(imageFile!.path)))
231+
kIsWeb ? Image.network(imageFile!.path) : Image.file(File(imageFile!.path)))
248232
: Container(
249-
decoration: BoxDecoration(
250-
border: Border.all(color: Colors.pink),
251-
),
233+
decoration: BoxDecoration(border: Border.all(color: Colors.pink)),
252234
child: Center(
253235
child: AspectRatio(
254236
aspectRatio: localVideoController.value.aspectRatio,
@@ -281,16 +263,12 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
281263
IconButton(
282264
icon: const Icon(Icons.exposure),
283265
color: Colors.blue,
284-
onPressed: controller != null
285-
? onExposureModeButtonPressed
286-
: null,
266+
onPressed: controller != null ? onExposureModeButtonPressed : null,
287267
),
288268
IconButton(
289269
icon: const Icon(Icons.filter_center_focus),
290270
color: Colors.blue,
291-
onPressed: controller != null
292-
? onFocusModeButtonPressed
293-
: null,
271+
onPressed: controller != null ? onFocusModeButtonPressed : null,
294272
),
295273
]
296274
: <Widget>[],
@@ -306,9 +284,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
306284
: Icons.screen_rotation,
307285
),
308286
color: Colors.blue,
309-
onPressed: controller != null
310-
? onCaptureOrientationLockButtonPressed
311-
: null,
287+
onPressed: controller != null ? onCaptureOrientationLockButtonPressed : null,
312288
),
313289
],
314290
),
@@ -328,36 +304,28 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
328304
children: <Widget>[
329305
IconButton(
330306
icon: const Icon(Icons.flash_off),
331-
color: controller?.value.flashMode == FlashMode.off
332-
? Colors.orange
333-
: Colors.blue,
307+
color: controller?.value.flashMode == FlashMode.off ? Colors.orange : Colors.blue,
334308
onPressed: controller != null
335309
? () => onSetFlashModeButtonPressed(FlashMode.off)
336310
: null,
337311
),
338312
IconButton(
339313
icon: const Icon(Icons.flash_auto),
340-
color: controller?.value.flashMode == FlashMode.auto
341-
? Colors.orange
342-
: Colors.blue,
314+
color: controller?.value.flashMode == FlashMode.auto ? Colors.orange : Colors.blue,
343315
onPressed: controller != null
344316
? () => onSetFlashModeButtonPressed(FlashMode.auto)
345317
: null,
346318
),
347319
IconButton(
348320
icon: const Icon(Icons.flash_on),
349-
color: controller?.value.flashMode == FlashMode.always
350-
? Colors.orange
351-
: Colors.blue,
321+
color: controller?.value.flashMode == FlashMode.always ? Colors.orange : Colors.blue,
352322
onPressed: controller != null
353323
? () => onSetFlashModeButtonPressed(FlashMode.always)
354324
: null,
355325
),
356326
IconButton(
357327
icon: const Icon(Icons.highlight),
358-
color: controller?.value.flashMode == FlashMode.torch
359-
? Colors.orange
360-
: Colors.blue,
328+
color: controller?.value.flashMode == FlashMode.torch ? Colors.orange : Colors.blue,
361329
onPressed: controller != null
362330
? () => onSetFlashModeButtonPressed(FlashMode.torch)
363331
: null,
@@ -394,15 +362,11 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
394362
TextButton(
395363
style: styleAuto,
396364
onPressed: controller != null
397-
? () =>
398-
onSetExposureModeButtonPressed(ExposureMode.auto)
365+
? () => onSetExposureModeButtonPressed(ExposureMode.auto)
399366
: null,
400367
onLongPress: () {
401368
if (controller != null) {
402-
CameraPlatform.instance.setExposurePoint(
403-
controller!.cameraId,
404-
null,
405-
);
369+
CameraPlatform.instance.setExposurePoint(controller!.cameraId, null);
406370
showInSnackBar('Resetting exposure point');
407371
}
408372
},
@@ -411,17 +375,13 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
411375
TextButton(
412376
style: styleLocked,
413377
onPressed: controller != null
414-
? () => onSetExposureModeButtonPressed(
415-
ExposureMode.locked,
416-
)
378+
? () => onSetExposureModeButtonPressed(ExposureMode.locked)
417379
: null,
418380
child: const Text('LOCKED'),
419381
),
420382
TextButton(
421383
style: styleLocked,
422-
onPressed: controller != null
423-
? () => controller!.setExposureOffset(0.0)
424-
: null,
384+
onPressed: controller != null ? () => controller!.setExposureOffset(0.0) : null,
425385
child: const Text('RESET OFFSET'),
426386
),
427387
],
@@ -436,9 +396,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
436396
min: _minAvailableExposureOffset,
437397
max: _maxAvailableExposureOffset,
438398
label: _currentExposureOffset.toString(),
439-
onChanged:
440-
_minAvailableExposureOffset ==
441-
_maxAvailableExposureOffset
399+
onChanged: _minAvailableExposureOffset == _maxAvailableExposureOffset
442400
? null
443401
: setExposureOffset,
444402
),
@@ -454,9 +412,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
454412

455413
Widget _focusModeControlRowWidget() {
456414
final ButtonStyle styleAuto = TextButton.styleFrom(
457-
foregroundColor: controller?.value.focusMode == FocusMode.auto
458-
? Colors.orange
459-
: Colors.blue,
415+
foregroundColor: controller?.value.focusMode == FocusMode.auto ? Colors.orange : Colors.blue,
460416
);
461417
final ButtonStyle styleLocked = TextButton.styleFrom(
462418
foregroundColor: controller?.value.focusMode == FocusMode.locked
@@ -482,10 +438,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
482438
: null,
483439
onLongPress: () {
484440
if (controller != null) {
485-
CameraPlatform.instance.setFocusPoint(
486-
controller!.cameraId,
487-
null,
488-
);
441+
CameraPlatform.instance.setFocusPoint(controller!.cameraId, null);
489442
}
490443
showInSnackBar('Resetting focus point');
491444
},
@@ -563,13 +516,10 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
563516
),
564517
IconButton(
565518
icon: const Icon(Icons.pause_presentation),
566-
color:
567-
cameraController != null && cameraController.value.isPreviewPaused
519+
color: cameraController != null && cameraController.value.isPreviewPaused
568520
? Colors.red
569521
: Colors.blue,
570-
onPressed: cameraController == null
571-
? null
572-
: onPausePreviewButtonPressed,
522+
onPressed: cameraController == null ? null : onPausePreviewButtonPressed,
573523
),
574524
],
575525
);
@@ -598,7 +548,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
598548
}
599549
}
600550

601-
final isRecording = controller?.value.isRecordingVideo ?? false;
551+
final bool isRecording = controller?.value.isRecordingVideo ?? false;
602552

603553
return RadioGroup<CameraDescription>(
604554
groupValue: controller?.description,
@@ -617,9 +567,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
617567
String timestamp() => DateTime.now().millisecondsSinceEpoch.toString();
618568

619569
void showInSnackBar(String message) {
620-
ScaffoldMessenger.of(
621-
context,
622-
).showSnackBar(SnackBar(content: Text(message)));
570+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(message)));
623571
}
624572

625573
void onViewFinderTap(TapDownDetails details, BoxConstraints constraints) {
@@ -645,9 +593,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
645593
}
646594
}
647595

648-
Future<void> _initializeCameraController(
649-
CameraDescription cameraDescription,
650-
) async {
596+
Future<void> _initializeCameraController(CameraDescription cameraDescription) async {
651597
final CameraController cameraController = CameraController(
652598
cameraDescription,
653599
kIsWeb ? ResolutionPreset.max : ResolutionPreset.medium,
@@ -672,14 +618,10 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
672618
? <Future<Object?>>[
673619
CameraPlatform.instance
674620
.getMinExposureOffset(cameraController.cameraId)
675-
.then(
676-
(double value) => _minAvailableExposureOffset = value,
677-
),
621+
.then((double value) => _minAvailableExposureOffset = value),
678622
CameraPlatform.instance
679623
.getMaxExposureOffset(cameraController.cameraId)
680-
.then(
681-
(double value) => _maxAvailableExposureOffset = value,
682-
),
624+
.then((double value) => _maxAvailableExposureOffset = value),
683625
]
684626
: <Future<Object?>>[],
685627
CameraPlatform.instance

0 commit comments

Comments
 (0)