Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ analyzer:
- '**/*.g.dart'
- '**/*.mocks.dart' # Mockito @GenerateMocks

# TODO(jsuya): Different from flutter/packages. Enable after reformatting the
# existing code, which is still formatted with the default line length of 80
# (https://github.com/flutter-tizen/plugins/issues/1089).
# formatter:
# page_width: 100
formatter:
page_width: 100

linter:
rules:
Expand Down Expand Up @@ -144,7 +141,7 @@ linter:
- null_check_on_nullable_type_parameter
- null_closures
# - omit_local_variable_types # superset of omit_obvious_local_variable_types
# - omit_obvious_local_variable_types # TODO(jsuya): Different from flutter/packages. Enable after migrating the existing code, which still follows the old always_specify_types style (https://github.com/flutter-tizen/plugins/issues/1089).
- omit_obvious_local_variable_types
# - omit_obvious_property_types # conflicts with type_annotate_public_apis
# - one_member_abstracts # too many false positives
- only_throw_errors # this does get disabled in a few places where we have legacy code that uses strings et al
Expand Down
5 changes: 5 additions & 0 deletions packages/camera/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## NEXT

* Omit obvious local variable types.
* Reformat with a line length of 100.

## 0.3.6

* Update code format.
Expand Down
42 changes: 19 additions & 23 deletions packages/camera/example/integration_test/camera_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ void main() {
await testDir.delete(recursive: true);
});

final Map<ResolutionPreset, Size> presetExpectedSizes =
<ResolutionPreset, Size>{
final presetExpectedSizes = <ResolutionPreset, Size>{
ResolutionPreset.medium: const Size(480, 720),
// Don't bother checking for max here since it could be anything.
};
Expand Down Expand Up @@ -55,7 +54,7 @@ void main() {
final XFile file = await controller.takePicture();

// Load picture
final File fileImage = File(file.path);
final fileImage = File(file.path);
final Image image = await decodeImageFromList(fileImage.readAsBytesSync());

// Verify image dimensions are as expected
Expand All @@ -73,11 +72,10 @@ void main() {
if (cameras.isEmpty) {
return;
}
for (final CameraDescription cameraDescription in cameras) {
bool previousPresetExactlySupported = true;
for (final MapEntry<ResolutionPreset, Size> preset
in presetExpectedSizes.entries) {
final CameraController controller = CameraController(
for (final cameraDescription in cameras) {
var previousPresetExactlySupported = true;
for (final MapEntry<ResolutionPreset, Size> preset in presetExpectedSizes.entries) {
final controller = CameraController(
cameraDescription,
preset.key,
);
Expand Down Expand Up @@ -111,8 +109,8 @@ void main() {
final XFile file = await controller.stopVideoRecording();

// Load video metadata
final File videoFile = File(file.path);
final VideoPlayerController videoController = VideoPlayerController.file(
final videoFile = File(file.path);
final videoController = VideoPlayerController.file(
videoFile,
);
await videoController.initialize();
Expand All @@ -133,11 +131,10 @@ void main() {
if (cameras.isEmpty) {
return;
}
for (final CameraDescription cameraDescription in cameras) {
bool previousPresetExactlySupported = true;
for (final MapEntry<ResolutionPreset, Size> preset
in presetExpectedSizes.entries) {
final CameraController controller = CameraController(
for (final cameraDescription in cameras) {
var previousPresetExactlySupported = true;
for (final MapEntry<ResolutionPreset, Size> preset in presetExpectedSizes.entries) {
final controller = CameraController(
cameraDescription,
preset.key,
);
Expand All @@ -163,7 +160,7 @@ void main() {
return;
}

final CameraController controller = CameraController(
final controller = CameraController(
cameras[0],
ResolutionPreset.low,
enableAudio: false,
Expand All @@ -173,7 +170,7 @@ void main() {
// await controller.prepareForVideoRecording();

int startPause;
int timePaused = 0;
var timePaused = 0;

await controller.startVideoRecording();
final int recordingStart = DateTime.now().millisecondsSinceEpoch;
Expand All @@ -196,11 +193,10 @@ void main() {
sleep(const Duration(milliseconds: 500));

final XFile file = await controller.stopVideoRecording();
final int recordingTime =
DateTime.now().millisecondsSinceEpoch - recordingStart;
final int recordingTime = DateTime.now().millisecondsSinceEpoch - recordingStart;

final File videoFile = File(file.path);
final VideoPlayerController videoController = VideoPlayerController.file(
final videoFile = File(file.path);
final videoController = VideoPlayerController.file(
videoFile,
);
await videoController.initialize();
Expand All @@ -216,14 +212,14 @@ void main() {
return;
}

final CameraController controller = CameraController(
final controller = CameraController(
cameras[0],
ResolutionPreset.low,
enableAudio: false,
);

await controller.initialize();
bool isDetecting = false;
var isDetecting = false;

await controller.startImageStream((CameraImage image) {
if (isDetecting) {
Expand Down
112 changes: 39 additions & 73 deletions packages/camera/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,9 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
decoration: BoxDecoration(
color: Colors.black,
border: Border.all(
color:
controller != null && controller!.value.isRecordingVideo
? Colors.redAccent
: Colors.grey,
color: controller != null && controller!.value.isRecordingVideo
? Colors.redAccent
: Colors.grey,
width: 3.0,
),
),
Expand Down Expand Up @@ -187,8 +186,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
behavior: HitTestBehavior.opaque,
onScaleStart: _handleScaleStart,
onScaleUpdate: _handleScaleUpdate,
onTapDown: (TapDownDetails details) =>
onViewFinderTap(details, constraints),
onTapDown: (TapDownDetails details) => onViewFinderTap(details, constraints),
);
},
),
Expand Down Expand Up @@ -237,9 +235,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
// pointing to a location within the browser. It may be displayed
// either with Image.network or Image.memory after loading the image
// bytes to memory.
kIsWeb
? Image.network(imageFile!.path)
: Image.file(File(imageFile!.path)))
kIsWeb ? Image.network(imageFile!.path) : Image.file(File(imageFile!.path)))
: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.pink),
Expand Down Expand Up @@ -276,15 +272,12 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
IconButton(
icon: const Icon(Icons.exposure),
color: Colors.blue,
onPressed: controller != null
? onExposureModeButtonPressed
: null,
onPressed: controller != null ? onExposureModeButtonPressed : null,
),
IconButton(
icon: const Icon(Icons.filter_center_focus),
color: Colors.blue,
onPressed:
controller != null ? onFocusModeButtonPressed : null,
onPressed: controller != null ? onFocusModeButtonPressed : null,
),
]
: <Widget>[],
Expand All @@ -300,9 +293,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
: Icons.screen_rotation,
),
color: Colors.blue,
onPressed: controller != null
? onCaptureOrientationLockButtonPressed
: null,
onPressed: controller != null ? onCaptureOrientationLockButtonPressed : null,
),
],
),
Expand All @@ -322,39 +313,27 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
children: <Widget>[
IconButton(
icon: const Icon(Icons.flash_off),
color: controller?.value.flashMode == FlashMode.off
? Colors.orange
: Colors.blue,
onPressed: controller != null
? () => onSetFlashModeButtonPressed(FlashMode.off)
: null,
color: controller?.value.flashMode == FlashMode.off ? Colors.orange : Colors.blue,
onPressed:
controller != null ? () => onSetFlashModeButtonPressed(FlashMode.off) : null,
),
IconButton(
icon: const Icon(Icons.flash_auto),
color: controller?.value.flashMode == FlashMode.auto
? Colors.orange
: Colors.blue,
onPressed: controller != null
? () => onSetFlashModeButtonPressed(FlashMode.auto)
: null,
color: controller?.value.flashMode == FlashMode.auto ? Colors.orange : Colors.blue,
onPressed:
controller != null ? () => onSetFlashModeButtonPressed(FlashMode.auto) : null,
),
IconButton(
icon: const Icon(Icons.flash_on),
color: controller?.value.flashMode == FlashMode.always
? Colors.orange
: Colors.blue,
onPressed: controller != null
? () => onSetFlashModeButtonPressed(FlashMode.always)
: null,
color: controller?.value.flashMode == FlashMode.always ? Colors.orange : Colors.blue,
onPressed:
controller != null ? () => onSetFlashModeButtonPressed(FlashMode.always) : null,
),
IconButton(
icon: const Icon(Icons.highlight),
color: controller?.value.flashMode == FlashMode.torch
? Colors.orange
: Colors.blue,
onPressed: controller != null
? () => onSetFlashModeButtonPressed(FlashMode.torch)
: null,
color: controller?.value.flashMode == FlashMode.torch ? Colors.orange : Colors.blue,
onPressed:
controller != null ? () => onSetFlashModeButtonPressed(FlashMode.torch) : null,
),
],
),
Expand All @@ -364,14 +343,12 @@ class _CameraExampleHomeState extends State<CameraExampleHome>

Widget _exposureModeControlRowWidget() {
final ButtonStyle styleAuto = TextButton.styleFrom(
backgroundColor: controller?.value.exposureMode == ExposureMode.auto
? Colors.orange
: Colors.blue,
backgroundColor:
controller?.value.exposureMode == ExposureMode.auto ? Colors.orange : Colors.blue,
);
final ButtonStyle styleLocked = TextButton.styleFrom(
backgroundColor: controller?.value.exposureMode == ExposureMode.locked
? Colors.orange
: Colors.blue,
backgroundColor:
controller?.value.exposureMode == ExposureMode.locked ? Colors.orange : Colors.blue,
);

return SizeTransition(
Expand Down Expand Up @@ -411,9 +388,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
),
TextButton(
style: styleLocked,
onPressed: controller != null
? () => controller!.setExposureOffset(0.0)
: null,
onPressed: controller != null ? () => controller!.setExposureOffset(0.0) : null,
child: const Text('RESET OFFSET'),
),
],
Expand All @@ -428,8 +403,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
min: _minAvailableExposureOffset,
max: _maxAvailableExposureOffset,
label: _currentExposureOffset.toString(),
onChanged: _minAvailableExposureOffset ==
_maxAvailableExposureOffset
onChanged: _minAvailableExposureOffset == _maxAvailableExposureOffset
? null
: setExposureOffset,
),
Expand All @@ -445,14 +419,11 @@ class _CameraExampleHomeState extends State<CameraExampleHome>

Widget _focusModeControlRowWidget() {
final ButtonStyle styleAuto = TextButton.styleFrom(
backgroundColor: controller?.value.focusMode == FocusMode.auto
? Colors.orange
: Colors.blue,
backgroundColor: controller?.value.focusMode == FocusMode.auto ? Colors.orange : Colors.blue,
);
final ButtonStyle styleLocked = TextButton.styleFrom(
backgroundColor: controller?.value.focusMode == FocusMode.locked
? Colors.orange
: Colors.blue,
backgroundColor:
controller?.value.focusMode == FocusMode.locked ? Colors.orange : Colors.blue,
);

return SizeTransition(
Expand Down Expand Up @@ -521,8 +492,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
: null,
),
IconButton(
icon: cameraController != null &&
cameraController.value.isRecordingPaused
icon: cameraController != null && cameraController.value.isRecordingPaused
? const Icon(Icons.play_arrow)
: const Icon(Icons.pause),
color: Colors.blue,
Expand All @@ -545,20 +515,18 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
),
IconButton(
icon: const Icon(Icons.pause_presentation),
color:
cameraController != null && cameraController.value.isPreviewPaused
? Colors.red
: Colors.blue,
onPressed:
cameraController == null ? null : onPausePreviewButtonPressed,
color: cameraController != null && cameraController.value.isPreviewPaused
? Colors.red
: Colors.blue,
onPressed: cameraController == null ? null : onPausePreviewButtonPressed,
),
],
);
}

/// Display a row of toggle to select the camera (or a message if no camera is available).
Widget _cameraTogglesRowWidget() {
final List<Widget> toggles = <Widget>[];
final toggles = <Widget>[];

void onChanged(CameraDescription? description) {
if (description == null) {
Expand All @@ -583,9 +551,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
groupValue: controller?.description,
value: cameraDescription,
onChanged:
controller != null && controller!.value.isRecordingVideo
? null
: onChanged,
controller != null && controller!.value.isRecordingVideo ? null : onChanged,
),
),
);
Expand All @@ -610,7 +576,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>

final CameraController cameraController = controller!;

final Offset offset = Offset(
final offset = Offset(
details.localPosition.dx / constraints.maxWidth,
details.localPosition.dy / constraints.maxHeight,
);
Expand All @@ -630,7 +596,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
await oldController.dispose();
}

final CameraController cameraController = CameraController(
final cameraController = CameraController(
cameraDescription,
kIsWeb ? ResolutionPreset.max : ResolutionPreset.medium,
enableAudio: enableAudio,
Expand Down Expand Up @@ -985,7 +951,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
return;
}

final VideoPlayerController vController = kIsWeb
final vController = kIsWeb
? VideoPlayerController.network(videoFile!.path)
: VideoPlayerController.file(File(videoFile!.path));

Expand Down
Loading
Loading