Skip to content

Commit 3a093e4

Browse files
[various] Enable avoid_print (#6842)
* [various] Enable avoid_print Enables the `avoid_print` lint, and fixes violations (mostly by opting example files out of it). * Version bumps * Add tooling analysis option file that was accidentally omitted * Fix typo in analysis_options found by adding tool sub-options * Revert most version bumps * Fix ios_platform_images
1 parent b2cdcb6 commit 3a093e4

File tree

60 files changed

+94
-93
lines changed

Some content is hidden

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

60 files changed

+94
-93
lines changed

analysis_options.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ linter:
8181
# - avoid_multiple_declarations_per_line # seems to be a stylistic choice we don't subscribe to
8282
- avoid_null_checks_in_equality_operators
8383
# - avoid_positional_boolean_parameters # would have been nice to enable this but by now there's too many places that break it
84-
# - avoid_print # LOCAL CHANGE - Needs to be enabled and violations fixed.
84+
- avoid_print
8585
# - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
8686
- avoid_redundant_argument_values
8787
- avoid_relative_lib_imports
@@ -204,7 +204,7 @@ linter:
204204
- recursive_getters
205205
# - require_trailing_commas # blocked on https://github.com/dart-lang/sdk/issues/47441
206206
- secure_pubspec_urls
207-
- sized_box_for_whitespace
207+
- sized_box_for_whitespace
208208
# - sized_box_shrink_expand # not yet tested
209209
- slash_for_doc_comments
210210
- sort_child_properties_last

packages/camera/camera/CHANGELOG.md

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

37
* Removes usage of `_ambiguate` method in example.

packages/camera/camera/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ class _CameraAppState extends State<CameraApp> {
141141
if (e is CameraException) {
142142
switch (e.code) {
143143
case 'CameraAccessDenied':
144-
print('User denied camera access.');
144+
// Handle access errors here.
145145
break;
146146
default:
147-
print('Handle other errors.');
147+
// Handle other errors here.
148148
break;
149149
}
150150
}

packages/camera/camera/example/integration_test/camera_test.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ void main() {
5555
Future<bool> testCaptureImageResolution(
5656
CameraController controller, ResolutionPreset preset) async {
5757
final Size expectedSize = presetExpectedSizes[preset]!;
58-
print(
59-
'Capturing photo at $preset (${expectedSize.width}x${expectedSize.height}) using camera ${controller.description.name}');
6058

6159
// Take Picture
6260
final XFile file = await controller.takePicture();
@@ -104,8 +102,6 @@ void main() {
104102
Future<bool> testCaptureVideoResolution(
105103
CameraController controller, ResolutionPreset preset) async {
106104
final Size expectedSize = presetExpectedSizes[preset]!;
107-
print(
108-
'Capturing video at $preset (${expectedSize.width}x${expectedSize.height}) using camera ${controller.description.name}');
109105

110106
// Take Video
111107
await controller.startVideoRecording();

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,8 @@ IconData getCameraLensIcon(CameraLensDirection direction) {
3737
}
3838

3939
void _logError(String code, String? message) {
40-
if (message != null) {
41-
print('Error: $code\nError Message: $message');
42-
} else {
43-
print('Error: $code');
44-
}
40+
// ignore: avoid_print
41+
print('Error: $code${message == null ? '' : '\nError Message: $message'}');
4542
}
4643

4744
class _CameraExampleHomeState extends State<CameraExampleHome>

packages/camera/camera/example/lib/readme_full_example.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ class _CameraAppState extends State<CameraApp> {
4040
if (e is CameraException) {
4141
switch (e.code) {
4242
case 'CameraAccessDenied':
43-
print('User denied camera access.');
43+
// Handle access errors here.
4444
break;
4545
default:
46-
print('Handle other errors.');
46+
// Handle other errors here.
4747
break;
4848
}
4949
}

packages/camera/camera/example/test_driver/integration_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
// ignore_for_file: avoid_print
6+
57
import 'dart:async';
68
import 'dart:convert';
79
import 'dart:io';

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.0+4
7+
version: 0.10.0+5
88

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

packages/camera/camera_android/example/integration_test/camera_test.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ void main() {
5555
Future<bool> testCaptureImageResolution(
5656
CameraController controller, ResolutionPreset preset) async {
5757
final Size expectedSize = presetExpectedSizes[preset]!;
58-
print(
59-
'Capturing photo at $preset (${expectedSize.width}x${expectedSize.height}) using camera ${controller.description.name}');
6058

6159
// Take Picture
6260
final XFile file = await controller.takePicture();
@@ -105,8 +103,6 @@ void main() {
105103
Future<bool> testCaptureVideoResolution(
106104
CameraController controller, ResolutionPreset preset) async {
107105
final Size expectedSize = presetExpectedSizes[preset]!;
108-
print(
109-
'Capturing video at $preset (${expectedSize.width}x${expectedSize.height}) using camera ${controller.description.name}');
110106

111107
// Take Video
112108
await controller.startVideoRecording();

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@ IconData getCameraLensIcon(CameraLensDirection direction) {
4141
}
4242

4343
void _logError(String code, String? message) {
44-
if (message != null) {
45-
print('Error: $code\nError Message: $message');
46-
} else {
47-
print('Error: $code');
48-
}
44+
// ignore: avoid_print
45+
print('Error: $code${message == null ? '' : '\nError Message: $message'}');
4946
}
5047

5148
class _CameraExampleHomeState extends State<CameraExampleHome>

0 commit comments

Comments
 (0)