Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 15 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
13 changes: 4 additions & 9 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,19 @@ linter:
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/linter/issues/453
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
# - no_default_cases # LOCAL CHANGE - Needs to be enabled and violations fixed.
- no_default_cases
- no_duplicate_case_values
- no_leading_underscores_for_library_prefixes
- no_leading_underscores_for_local_identifiers
- no_logic_in_create_state
# - no_runtimeType_toString # ok in tests; we enable this only in packages/
- no_runtimeType_toString # DIFFERENT FROM FLUTTER/FLUTTER
- non_constant_identifier_names
- noop_primitive_operations
- null_check_on_nullable_type_parameter
- null_closures
# - omit_local_variable_types # opposite of always_specify_types
# - 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 # LOCAL CHANGE - Needs to be enabled and violations fixed.
- only_throw_errors # this does get disabled in a few places where we have legacy code that uses strings et al
- overridden_fields
- package_api_docs
- package_names
Expand Down Expand Up @@ -200,7 +200,7 @@ linter:
- prefer_typing_uninitialized_variables
- prefer_void_to_null
- provide_deprecation_message
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
- public_member_api_docs # DIFFERENT FROM FLUTTER/FLUTTER
- recursive_getters
# - require_trailing_commas # blocked on https://github.com/dart-lang/sdk/issues/47441
- secure_pubspec_urls
Expand Down Expand Up @@ -261,8 +261,3 @@ linter:
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
- valid_regexps
- void_checks
### Local flutter/plugins additions ###
# These are from flutter/flutter/packages, so will need to be preserved
# separately when moving to a shared file.
- no_runtimeType_toString # use objectRuntimeType from package:foundation
- public_member_api_docs # see https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#documentation-dartdocs-javadocs-etc
4 changes: 4 additions & 0 deletions packages/camera/camera/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.10.1+1

* Updates code for stricter lint checks.

## 0.10.1

* Remove usage of deprecated quiver Optional type.
Expand Down
6 changes: 4 additions & 2 deletions packages/camera/camera/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ IconData getCameraLensIcon(CameraLensDirection direction) {
case CameraLensDirection.front:
return Icons.camera_front;
case CameraLensDirection.external:
return Icons.camera;
// This enum is from a different package, so a new value could be added at
// any time. The example should keep working if that happens.
// ignore: no_default_cases
default:
throw ArgumentError('Unknown lens direction');
return Icons.camera;
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A Flutter plugin for controlling the camera. Supports previewing
Dart.
repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.10.1
version: 0.10.1+1

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down
4 changes: 4 additions & 0 deletions packages/camera/camera_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.10.2+2

* Updates code for stricter lint checks.

## 0.10.2+1

* Updates code for stricter lint checks.
Expand Down
6 changes: 4 additions & 2 deletions packages/camera/camera_android/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ IconData getCameraLensIcon(CameraLensDirection direction) {
case CameraLensDirection.front:
return Icons.camera_front;
case CameraLensDirection.external:
return Icons.camera;
// This enum is from a different package, so a new value could be added at
// any time. The example should keep working if that happens.
// ignore: no_default_cases
default:
throw ArgumentError('Unknown lens direction');
return Icons.camera;
}
}

Expand Down
19 changes: 15 additions & 4 deletions packages/camera/camera_android/lib/src/android_camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class AndroidCamera extends CameraPlatform {
// ignore: body_might_complete_normally_catch_error
(Object error, StackTrace stackTrace) {
if (error is! PlatformException) {
// ignore: only_throw_errors
throw error;
}
completer.completeError(
Expand Down Expand Up @@ -520,9 +521,14 @@ class AndroidCamera extends CameraPlatform {
return 'always';
case FlashMode.torch:
return 'torch';
default:
throw ArgumentError('Unknown FlashMode value');
}
// The enum comes from a different package, which could get a new value at
// any time, so provide a fallback that ensures this won't break when used
// with a version that contains new values. This is deliberately outside
// the switch rather than a `default` so that the linter will flag the
// switch as needing an update.
// ignore: dead_code
return 'off';
}

/// Returns the resolution preset as a String.
Expand All @@ -540,9 +546,14 @@ class AndroidCamera extends CameraPlatform {
return 'medium';
case ResolutionPreset.low:
return 'low';
default:
throw ArgumentError('Unknown ResolutionPreset value');
}
// The enum comes from a different package, which could get a new value at
// any time, so provide a fallback that ensures this won't break when used
// with a version that contains new values. This is deliberately outside
// the switch rather than a `default` so that the linter will flag the
// switch as needing an update.
// ignore: dead_code
return 'max';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should just keep the old behavior of throwing? It seems like in most of these cases you can keep the same behavior by removing the exception outside of the default branch which would keep the same logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could keep the same logic, but I changed it because throwing seems very extreme to me when there's a reasonable fallback.

When these switches were first written, everything was one package and this case meant that we'd forgotten to implement something, so it was a bug. Now it means that a client is using an implementation version that doesn't support that option yet, so a fallback seems better to me.

}

/// Converts messages received from the native platform into device events.
Expand Down
9 changes: 7 additions & 2 deletions packages/camera/camera_android/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ String serializeDeviceOrientation(DeviceOrientation orientation) {
return 'landscapeRight';
case DeviceOrientation.landscapeLeft:
return 'landscapeLeft';
default:
throw ArgumentError('Unknown DeviceOrientation value');
}
// The enum comes from a different package, which could get a new value at
// any time, so provide a fallback that ensures this won't break when used
// with a version that contains new values. This is deliberately outside
// the switch rather than a `default` so that the linter will flag the
// switch as needing an update.
// ignore: dead_code
return 'portraitUp';
}

/// Returns the device orientation for a given String.
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera_android
description: Android implementation of the camera plugin.
repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.10.2+1
version: 0.10.2+2

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down
4 changes: 4 additions & 0 deletions packages/camera/camera_avfoundation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.10+2

* Updates code for stricter lint checks.

## 0.9.10+1

* Updates code for stricter lint checks.
Expand Down
6 changes: 4 additions & 2 deletions packages/camera/camera_avfoundation/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ IconData getCameraLensIcon(CameraLensDirection direction) {
case CameraLensDirection.front:
return Icons.camera_front;
case CameraLensDirection.external:
return Icons.camera;
// This enum is from a different package, so a new value could be added at
// any time. The example should keep working if that happens.
// ignore: no_default_cases
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for here

default:
throw ArgumentError('Unknown lens direction');
return Icons.camera;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class AVFoundationCamera extends CameraPlatform {
// ignore: body_might_complete_normally_catch_error
(Object error, StackTrace stackTrace) {
if (error is! PlatformException) {
// ignore: only_throw_errors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be addressed instead of ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In practice this is only a violation if invokeMapMethod is violating the lint, since we're just rethrowing the same object. That seemed unlikely enough that I didn't think it was worth worrying about given that the plan is to migrate all plugins to Pigeon over time, and this code would be eliminated in a Pigeon migration.

throw error;
}
completer.completeError(
Expand Down Expand Up @@ -526,9 +527,14 @@ class AVFoundationCamera extends CameraPlatform {
return 'always';
case FlashMode.torch:
return 'torch';
default:
throw ArgumentError('Unknown FlashMode value');
}
// The enum comes from a different package, which could get a new value at
// any time, so provide a fallback that ensures this won't break when used
// with a version that contains new values. This is deliberately outside
// the switch rather than a `default` so that the linter will flag the
// switch as needing an update.
// ignore: dead_code
return 'off';
}

/// Returns the resolution preset as a String.
Expand All @@ -546,9 +552,14 @@ class AVFoundationCamera extends CameraPlatform {
return 'medium';
case ResolutionPreset.low:
return 'low';
default:
throw ArgumentError('Unknown ResolutionPreset value');
}
// The enum comes from a different package, which could get a new value at
// any time, so provide a fallback that ensures this won't break when used
// with a version that contains new values. This is deliberately outside
// the switch rather than a `default` so that the linter will flag the
// switch as needing an update.
// ignore: dead_code
return 'max';
}

/// Converts messages received from the native platform into device events.
Expand Down
9 changes: 7 additions & 2 deletions packages/camera/camera_avfoundation/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ String serializeDeviceOrientation(DeviceOrientation orientation) {
return 'landscapeRight';
case DeviceOrientation.landscapeLeft:
return 'landscapeLeft';
default:
throw ArgumentError('Unknown DeviceOrientation value');
}
// The enum comes from a different package, which could get a new value at
// any time, so provide a fallback that ensures this won't break when used
// with a version that contains new values. This is deliberately outside
// the switch rather than a `default` so that the linter will flag the
// switch as needing an update.
// ignore: dead_code
return 'portraitUp';
}

/// Returns the device orientation for a given String.
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_avfoundation/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera_avfoundation
description: iOS implementation of the camera plugin.
repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera_avfoundation
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.9.10+1
version: 0.9.10+2

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down
4 changes: 4 additions & 0 deletions packages/camera/camera_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.3.4

* Updates code for stricter lint checks.

## 2.3.3

* Updates code for stricter lint checks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class MethodChannelCamera extends CameraPlatform {
// ignore: body_might_complete_normally_catch_error
(Object error, StackTrace stackTrace) {
if (error is! PlatformException) {
// ignore: only_throw_errors
throw error;
}
completer.completeError(
Expand Down Expand Up @@ -519,8 +520,6 @@ class MethodChannelCamera extends CameraPlatform {
return 'always';
case FlashMode.torch:
return 'torch';
default:
throw ArgumentError('Unknown FlashMode value');
}
}

Expand All @@ -539,8 +538,6 @@ class MethodChannelCamera extends CameraPlatform {
return 'medium';
case ResolutionPreset.low:
return 'low';
default:
throw ArgumentError('Unknown ResolutionPreset value');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ String serializeExposureMode(ExposureMode exposureMode) {
return 'locked';
case ExposureMode.auto:
return 'auto';
default:
throw ArgumentError('Unknown ExposureMode value');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ String serializeFocusMode(FocusMode focusMode) {
return 'locked';
case FocusMode.auto:
return 'auto';
default:
throw ArgumentError('Unknown FocusMode value');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ extension ImageFormatGroupName on ImageFormatGroup {
case ImageFormatGroup.jpeg:
return 'jpeg';
case ImageFormatGroup.unknown:
default:
return 'unknown';
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ String serializeDeviceOrientation(DeviceOrientation orientation) {
return 'landscapeRight';
case DeviceOrientation.landscapeLeft:
return 'landscapeLeft';
default:
throw ArgumentError('Unknown DeviceOrientation value');
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera_
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 2.3.3
version: 2.3.4

environment:
sdk: '>=2.12.0 <3.0.0'
Expand Down
4 changes: 4 additions & 0 deletions packages/camera/camera_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.1+1

* Updates code for stricter lint checks.

## 0.3.1

* Updates to latest camera platform interface, and fails if user attempts to use streaming with recording (since streaming is currently unsupported on web).
Expand Down
8 changes: 7 additions & 1 deletion packages/camera/camera_web/lib/src/camera_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,15 @@ class CameraService {
case ResolutionPreset.medium:
return const Size(720, 480);
case ResolutionPreset.low:
default:
return const Size(320, 240);
}
// The enum comes from a different package, which could get a new value at
// any time, so provide a fallback that ensures this won't break when used
// with a version that contains new values. This is deliberately outside
// the switch rather than a `default` so that the linter will flag the
// switch as needing an update.
// ignore: dead_code
return const Size(320, 240);
}

/// Maps the given [deviceOrientation] to [OrientationType].
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera_web
description: A Flutter plugin for getting information about and controlling the camera on Web.
repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.3.1
version: 0.3.1+1

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.4.3

* Updates code for stricter lint checks.

## 2.4.2

* Updates code for stricter lint checks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
preferredRenderer = 'legacy';
break;
case AndroidMapRenderer.platformDefault:
default:
case null:
preferredRenderer = 'default';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_maps_flutter_android
description: Android implementation of the google_maps_flutter plugin.
repository: https://github.com/flutter/plugins/tree/main/packages/google_maps_flutter/google_maps_flutter_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
version: 2.4.2
version: 2.4.3

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.0+5

* Updates code for stricter lint checks.

## 0.4.0+4

* Updates code for stricter lint checks.
Expand Down
Loading