Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 783ce6d

Browse files
[various] More analysis_options alignment (#6949)
* Change the way local changes are handled to match packages * only_throw_errors * Enable no_default_cases * Fix violations in camera * Fix violations in webview * Fix url_launcher violation * Fix violations in shared_preferences * Fix violations in maps * Version bumps * Fix image_picker violations * Fix video_player violations * New version bumps * Update excerpts * Address review feedback
1 parent ffb36e0 commit 783ce6d

File tree

89 files changed

+281
-128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+281
-128
lines changed

analysis_options.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,19 @@ linter:
141141
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/linter/issues/453
142142
- missing_whitespace_between_adjacent_strings
143143
- no_adjacent_strings_in_list
144-
# - no_default_cases # LOCAL CHANGE - Needs to be enabled and violations fixed.
144+
- no_default_cases
145145
- no_duplicate_case_values
146146
- no_leading_underscores_for_library_prefixes
147147
- no_leading_underscores_for_local_identifiers
148148
- no_logic_in_create_state
149-
# - no_runtimeType_toString # ok in tests; we enable this only in packages/
149+
- no_runtimeType_toString # DIFFERENT FROM FLUTTER/FLUTTER
150150
- non_constant_identifier_names
151151
- noop_primitive_operations
152152
- null_check_on_nullable_type_parameter
153153
- null_closures
154154
# - omit_local_variable_types # opposite of always_specify_types
155155
# - one_member_abstracts # too many false positives
156-
# - 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.
156+
- only_throw_errors # this does get disabled in a few places where we have legacy code that uses strings et al
157157
- overridden_fields
158158
- package_api_docs
159159
- package_names
@@ -200,7 +200,7 @@ linter:
200200
- prefer_typing_uninitialized_variables
201201
- prefer_void_to_null
202202
- provide_deprecation_message
203-
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
203+
- public_member_api_docs # DIFFERENT FROM FLUTTER/FLUTTER
204204
- recursive_getters
205205
# - require_trailing_commas # blocked on https://github.com/dart-lang/sdk/issues/47441
206206
- secure_pubspec_urls
@@ -261,8 +261,3 @@ linter:
261261
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
262262
- valid_regexps
263263
- void_checks
264-
### Local flutter/plugins additions ###
265-
# These are from flutter/flutter/packages, so will need to be preserved
266-
# separately when moving to a shared file.
267-
- no_runtimeType_toString # use objectRuntimeType from package:foundation
268-
- public_member_api_docs # see https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#documentation-dartdocs-javadocs-etc

packages/camera/camera/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.10.2+1
2+
3+
* Updates code for stricter lint checks.
4+
15
## 0.10.2
26

37
* Implements option to also stream when recording a video.
@@ -31,7 +35,7 @@
3135
## 0.10.0
3236

3337
* **Breaking Change** Bumps default camera_web package version, which updates permission exception code from `cameraPermission` to `CameraAccessDenied`.
34-
* **Breaking Change** Bumps default camera_android package version, which updates permission exception code from `cameraPermission` to
38+
* **Breaking Change** Bumps default camera_android package version, which updates permission exception code from `cameraPermission` to
3539
`CameraAccessDenied` and `AudioAccessDenied`.
3640
* Ignores unnecessary import warnings in preparation for [upcoming Flutter changes](https://github.com/flutter/flutter/pull/106316).
3741

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ IconData getCameraLensIcon(CameraLensDirection direction) {
3131
return Icons.camera_front;
3232
case CameraLensDirection.external:
3333
return Icons.camera;
34-
default:
35-
throw ArgumentError('Unknown lens direction');
3634
}
35+
// This enum is from a different package, so a new value could be added at
36+
// any time. The example should keep working if that happens.
37+
// ignore: dead_code
38+
return Icons.camera;
3739
}
3840

3941
void _logError(String code, String? message) {

packages/camera/camera/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: A Flutter plugin for controlling the camera. Supports previewing
44
Dart.
55
repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera
66
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
7-
version: 0.10.2
7+
version: 0.10.2+1
88

99
environment:
1010
sdk: ">=2.14.0 <3.0.0"

packages/camera/camera_android/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
## 0.10.2+3
2+
3+
* Updates code for stricter lint checks.
4+
15
## 0.10.2+2
26

37
* Fixes zoom computation for virtual cameras hiding physical cameras in Android 11+.
4-
* Removes the unused CameraZoom class from the codebase.
8+
* Removes the unused CameraZoom class from the codebase.
59

610
## 0.10.2+1
711

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ IconData getCameraLensIcon(CameraLensDirection direction) {
3535
return Icons.camera_front;
3636
case CameraLensDirection.external:
3737
return Icons.camera;
38-
default:
39-
throw ArgumentError('Unknown lens direction');
4038
}
39+
// This enum is from a different package, so a new value could be added at
40+
// any time. The example should keep working if that happens.
41+
// ignore: dead_code
42+
return Icons.camera;
4143
}
4244

4345
void _logError(String code, String? message) {

packages/camera/camera_android/lib/src/android_camera.dart

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ class AndroidCamera extends CameraPlatform {
145145
// ignore: body_might_complete_normally_catch_error
146146
(Object error, StackTrace stackTrace) {
147147
if (error is! PlatformException) {
148+
// ignore: only_throw_errors
148149
throw error;
149150
}
150151
completer.completeError(
@@ -520,9 +521,14 @@ class AndroidCamera extends CameraPlatform {
520521
return 'always';
521522
case FlashMode.torch:
522523
return 'torch';
523-
default:
524-
throw ArgumentError('Unknown FlashMode value');
525524
}
525+
// The enum comes from a different package, which could get a new value at
526+
// any time, so provide a fallback that ensures this won't break when used
527+
// with a version that contains new values. This is deliberately outside
528+
// the switch rather than a `default` so that the linter will flag the
529+
// switch as needing an update.
530+
// ignore: dead_code
531+
return 'off';
526532
}
527533

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

548559
/// Converts messages received from the native platform into device events.

packages/camera/camera_android/lib/src/utils.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,14 @@ String serializeDeviceOrientation(DeviceOrientation orientation) {
2929
return 'landscapeRight';
3030
case DeviceOrientation.landscapeLeft:
3131
return 'landscapeLeft';
32-
default:
33-
throw ArgumentError('Unknown DeviceOrientation value');
3432
}
33+
// The enum comes from a different package, which could get a new value at
34+
// any time, so provide a fallback that ensures this won't break when used
35+
// with a version that contains new values. This is deliberately outside
36+
// the switch rather than a `default` so that the linter will flag the
37+
// switch as needing an update.
38+
// ignore: dead_code
39+
return 'portraitUp';
3540
}
3641

3742
/// Returns the device orientation for a given String.

packages/camera/camera_android/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera_android
22
description: Android implementation of the camera plugin.
33
repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
5-
version: 0.10.2+2
5+
version: 0.10.2+3
66

77
environment:
88
sdk: ">=2.14.0 <3.0.0"

packages/camera/camera_avfoundation/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.9.10+2
2+
3+
* Updates code for stricter lint checks.
4+
15
## 0.9.10+1
26

37
* Updates code for stricter lint checks.

0 commit comments

Comments
 (0)