[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
diff --git a/analysis_options.yaml b/analysis_options.yaml
index c4fe482..0e07b33 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -81,7 +81,7 @@
# - avoid_multiple_declarations_per_line # seems to be a stylistic choice we don't subscribe to
- avoid_null_checks_in_equality_operators
# - avoid_positional_boolean_parameters # would have been nice to enable this but by now there's too many places that break it
- # - avoid_print # LOCAL CHANGE - Needs to be enabled and violations fixed.
+ - avoid_print
# - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
- avoid_redundant_argument_values
- avoid_relative_lib_imports
@@ -204,7 +204,7 @@
- recursive_getters
# - require_trailing_commas # blocked on https://github.com/dart-lang/sdk/issues/47441
- secure_pubspec_urls
- - sized_box_for_whitespace
+ - sized_box_for_whitespace
# - sized_box_shrink_expand # not yet tested
- slash_for_doc_comments
- sort_child_properties_last
diff --git a/packages/camera/camera/CHANGELOG.md b/packages/camera/camera/CHANGELOG.md
index 127da45..f5d87a6 100644
--- a/packages/camera/camera/CHANGELOG.md
+++ b/packages/camera/camera/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.10.0+5
+
+* Updates code for stricter lint checks.
+
## 0.10.0+4
* Removes usage of `_ambiguate` method in example.
diff --git a/packages/camera/camera/README.md b/packages/camera/camera/README.md
index 4d7c3d9..86b0355 100644
--- a/packages/camera/camera/README.md
+++ b/packages/camera/camera/README.md
@@ -141,10 +141,10 @@
if (e is CameraException) {
switch (e.code) {
case 'CameraAccessDenied':
- print('User denied camera access.');
+ // Handle access errors here.
break;
default:
- print('Handle other errors.');
+ // Handle other errors here.
break;
}
}
diff --git a/packages/camera/camera/example/integration_test/camera_test.dart b/packages/camera/camera/example/integration_test/camera_test.dart
index b233d49..f0cc67f 100644
--- a/packages/camera/camera/example/integration_test/camera_test.dart
+++ b/packages/camera/camera/example/integration_test/camera_test.dart
@@ -55,8 +55,6 @@
Future<bool> testCaptureImageResolution(
CameraController controller, ResolutionPreset preset) async {
final Size expectedSize = presetExpectedSizes[preset]!;
- print(
- 'Capturing photo at $preset (${expectedSize.width}x${expectedSize.height}) using camera ${controller.description.name}');
// Take Picture
final XFile file = await controller.takePicture();
@@ -104,8 +102,6 @@
Future<bool> testCaptureVideoResolution(
CameraController controller, ResolutionPreset preset) async {
final Size expectedSize = presetExpectedSizes[preset]!;
- print(
- 'Capturing video at $preset (${expectedSize.width}x${expectedSize.height}) using camera ${controller.description.name}');
// Take Video
await controller.startVideoRecording();
diff --git a/packages/camera/camera/example/lib/main.dart b/packages/camera/camera/example/lib/main.dart
index 860263e..4911625 100644
--- a/packages/camera/camera/example/lib/main.dart
+++ b/packages/camera/camera/example/lib/main.dart
@@ -37,11 +37,8 @@
}
void _logError(String code, String? message) {
- if (message != null) {
- print('Error: $code\nError Message: $message');
- } else {
- print('Error: $code');
- }
+ // ignore: avoid_print
+ print('Error: $code${message == null ? '' : '\nError Message: $message'}');
}
class _CameraExampleHomeState extends State<CameraExampleHome>
diff --git a/packages/camera/camera/example/lib/readme_full_example.dart b/packages/camera/camera/example/lib/readme_full_example.dart
index a3c232e..20bfe78 100644
--- a/packages/camera/camera/example/lib/readme_full_example.dart
+++ b/packages/camera/camera/example/lib/readme_full_example.dart
@@ -40,10 +40,10 @@
if (e is CameraException) {
switch (e.code) {
case 'CameraAccessDenied':
- print('User denied camera access.');
+ // Handle access errors here.
break;
default:
- print('Handle other errors.');
+ // Handle other errors here.
break;
}
}
diff --git a/packages/camera/camera/example/test_driver/integration_test.dart b/packages/camera/camera/example/test_driver/integration_test.dart
index 4ec97e6..aa57599 100644
--- a/packages/camera/camera/example/test_driver/integration_test.dart
+++ b/packages/camera/camera/example/test_driver/integration_test.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// ignore_for_file: avoid_print
+
import 'dart:async';
import 'dart:convert';
import 'dart:io';
diff --git a/packages/camera/camera/pubspec.yaml b/packages/camera/camera/pubspec.yaml
index 0f75d10..a867a5a 100644
--- a/packages/camera/camera/pubspec.yaml
+++ b/packages/camera/camera/pubspec.yaml
@@ -4,7 +4,7 @@
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.0+4
+version: 0.10.0+5
environment:
sdk: ">=2.14.0 <3.0.0"
diff --git a/packages/camera/camera_android/example/integration_test/camera_test.dart b/packages/camera/camera_android/example/integration_test/camera_test.dart
index 0ddb663..e499872 100644
--- a/packages/camera/camera_android/example/integration_test/camera_test.dart
+++ b/packages/camera/camera_android/example/integration_test/camera_test.dart
@@ -55,8 +55,6 @@
Future<bool> testCaptureImageResolution(
CameraController controller, ResolutionPreset preset) async {
final Size expectedSize = presetExpectedSizes[preset]!;
- print(
- 'Capturing photo at $preset (${expectedSize.width}x${expectedSize.height}) using camera ${controller.description.name}');
// Take Picture
final XFile file = await controller.takePicture();
@@ -105,8 +103,6 @@
Future<bool> testCaptureVideoResolution(
CameraController controller, ResolutionPreset preset) async {
final Size expectedSize = presetExpectedSizes[preset]!;
- print(
- 'Capturing video at $preset (${expectedSize.width}x${expectedSize.height}) using camera ${controller.description.name}');
// Take Video
await controller.startVideoRecording();
diff --git a/packages/camera/camera_android/example/lib/main.dart b/packages/camera/camera_android/example/lib/main.dart
index 9ebc27e..af9aab1 100644
--- a/packages/camera/camera_android/example/lib/main.dart
+++ b/packages/camera/camera_android/example/lib/main.dart
@@ -41,11 +41,8 @@
}
void _logError(String code, String? message) {
- if (message != null) {
- print('Error: $code\nError Message: $message');
- } else {
- print('Error: $code');
- }
+ // ignore: avoid_print
+ print('Error: $code${message == null ? '' : '\nError Message: $message'}');
}
class _CameraExampleHomeState extends State<CameraExampleHome>
diff --git a/packages/camera/camera_android/example/test_driver/integration_test.dart b/packages/camera/camera_android/example/test_driver/integration_test.dart
index 4ec97e6..aa57599 100644
--- a/packages/camera/camera_android/example/test_driver/integration_test.dart
+++ b/packages/camera/camera_android/example/test_driver/integration_test.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// ignore_for_file: avoid_print
+
import 'dart:async';
import 'dart:convert';
import 'dart:io';
diff --git a/packages/camera/camera_avfoundation/example/integration_test/camera_test.dart b/packages/camera/camera_avfoundation/example/integration_test/camera_test.dart
index 2b23d82..34d460d 100644
--- a/packages/camera/camera_avfoundation/example/integration_test/camera_test.dart
+++ b/packages/camera/camera_avfoundation/example/integration_test/camera_test.dart
@@ -56,8 +56,6 @@
Future<bool> testCaptureImageResolution(
CameraController controller, ResolutionPreset preset) async {
final Size expectedSize = presetExpectedSizes[preset]!;
- print(
- 'Capturing photo at $preset (${expectedSize.width}x${expectedSize.height}) using camera ${controller.description.name}');
// Take Picture
final XFile file = await controller.takePicture();
@@ -102,8 +100,6 @@
Future<bool> testCaptureVideoResolution(
CameraController controller, ResolutionPreset preset) async {
final Size expectedSize = presetExpectedSizes[preset]!;
- print(
- 'Capturing video at $preset (${expectedSize.width}x${expectedSize.height}) using camera ${controller.description.name}');
// Take Video
await controller.startVideoRecording();
diff --git a/packages/camera/camera_avfoundation/example/lib/main.dart b/packages/camera/camera_avfoundation/example/lib/main.dart
index 9ebc27e..af9aab1 100644
--- a/packages/camera/camera_avfoundation/example/lib/main.dart
+++ b/packages/camera/camera_avfoundation/example/lib/main.dart
@@ -41,11 +41,8 @@
}
void _logError(String code, String? message) {
- if (message != null) {
- print('Error: $code\nError Message: $message');
- } else {
- print('Error: $code');
- }
+ // ignore: avoid_print
+ print('Error: $code${message == null ? '' : '\nError Message: $message'}');
}
class _CameraExampleHomeState extends State<CameraExampleHome>
diff --git a/packages/camera/camera_web/test/more_tests_exist_elsewhere_test.dart b/packages/camera/camera_web/test/more_tests_exist_elsewhere_test.dart
index dc2b64c..32f037e 100644
--- a/packages/camera/camera_web/test/more_tests_exist_elsewhere_test.dart
+++ b/packages/camera/camera_web/test/more_tests_exist_elsewhere_test.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// ignore_for_file: avoid_print
+
import 'package:flutter_test/flutter_test.dart';
void main() {
diff --git a/packages/file_selector/file_selector/example/lib/save_text_page.dart b/packages/file_selector/file_selector/example/lib/save_text_page.dart
index 6dc765f..0a49e6f 100644
--- a/packages/file_selector/file_selector/example/lib/save_text_page.dart
+++ b/packages/file_selector/file_selector/example/lib/save_text_page.dart
@@ -56,7 +56,7 @@
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
- Container(
+ SizedBox(
width: 300,
child: TextField(
minLines: 1,
@@ -67,7 +67,7 @@
),
),
),
- Container(
+ SizedBox(
width: 300,
child: TextField(
minLines: 1,
diff --git a/packages/file_selector/file_selector_linux/example/lib/save_text_page.dart b/packages/file_selector/file_selector_linux/example/lib/save_text_page.dart
index 9803f28..aca041f 100644
--- a/packages/file_selector/file_selector_linux/example/lib/save_text_page.dart
+++ b/packages/file_selector/file_selector_linux/example/lib/save_text_page.dart
@@ -42,7 +42,7 @@
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
- Container(
+ SizedBox(
width: 300,
child: TextField(
minLines: 1,
@@ -53,7 +53,7 @@
),
),
),
- Container(
+ SizedBox(
width: 300,
child: TextField(
minLines: 1,
diff --git a/packages/file_selector/file_selector_macos/example/lib/save_text_page.dart b/packages/file_selector/file_selector_macos/example/lib/save_text_page.dart
index 3f215fe..f80aead 100644
--- a/packages/file_selector/file_selector_macos/example/lib/save_text_page.dart
+++ b/packages/file_selector/file_selector_macos/example/lib/save_text_page.dart
@@ -42,7 +42,7 @@
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
- Container(
+ SizedBox(
width: 300,
child: TextField(
minLines: 1,
@@ -53,7 +53,7 @@
),
),
),
- Container(
+ SizedBox(
width: 300,
child: TextField(
minLines: 1,
diff --git a/packages/file_selector/file_selector_web/test/more_tests_exist_elsewhere_test.dart b/packages/file_selector/file_selector_web/test/more_tests_exist_elsewhere_test.dart
index 37c6eb6..2fef89b 100644
--- a/packages/file_selector/file_selector_web/test/more_tests_exist_elsewhere_test.dart
+++ b/packages/file_selector/file_selector_web/test/more_tests_exist_elsewhere_test.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// ignore_for_file: avoid_print
+
import 'package:flutter_test/flutter_test.dart';
void main() {
diff --git a/packages/file_selector/file_selector_windows/example/lib/save_text_page.dart b/packages/file_selector/file_selector_windows/example/lib/save_text_page.dart
index 9803f28..aca041f 100644
--- a/packages/file_selector/file_selector_windows/example/lib/save_text_page.dart
+++ b/packages/file_selector/file_selector_windows/example/lib/save_text_page.dart
@@ -42,7 +42,7 @@
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
- Container(
+ SizedBox(
width: 300,
child: TextField(
minLines: 1,
@@ -53,7 +53,7 @@
),
),
),
- Container(
+ SizedBox(
width: 300,
child: TextField(
minLines: 1,
diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/map_coordinates.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/map_coordinates.dart
index 12e31be..efb4a10 100644
--- a/packages/google_maps_flutter/google_maps_flutter/example/lib/map_coordinates.dart
+++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/map_coordinates.dart
@@ -72,7 +72,7 @@
// Add a block at the bottom of this list to allow validation that the visible region of the map
// does not change when scrolled under the safe view on iOS.
// https://github.com/flutter/flutter/issues/107913
- Container(
+ const SizedBox(
width: 300,
height: 1000,
),
diff --git a/packages/google_maps_flutter/google_maps_flutter/test/circle_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/circle_updates_test.dart
index 6d65066..c6e7113 100644
--- a/packages/google_maps_flutter/google_maps_flutter/test/circle_updates_test.dart
+++ b/packages/google_maps_flutter/google_maps_flutter/test/circle_updates_test.dart
@@ -180,8 +180,7 @@
testWidgets('Update non platform related attr', (WidgetTester tester) async {
Circle c1 = const Circle(circleId: CircleId('circle_1'));
final Set<Circle> prev = <Circle>{c1};
- c1 = Circle(
- circleId: const CircleId('circle_1'), onTap: () => print('hello'));
+ c1 = Circle(circleId: const CircleId('circle_1'), onTap: () {});
final Set<Circle> cur = <Circle>{c1};
await tester.pumpWidget(_mapWithCircles(prev));
diff --git a/packages/google_maps_flutter/google_maps_flutter/test/marker_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/marker_updates_test.dart
index b5bba55..0acde97 100644
--- a/packages/google_maps_flutter/google_maps_flutter/test/marker_updates_test.dart
+++ b/packages/google_maps_flutter/google_maps_flutter/test/marker_updates_test.dart
@@ -185,8 +185,8 @@
final Set<Marker> prev = <Marker>{m1};
m1 = Marker(
markerId: const MarkerId('marker_1'),
- onTap: () => print('hello'),
- onDragEnd: (LatLng latLng) => print(latLng));
+ onTap: () {},
+ onDragEnd: (LatLng latLng) {});
final Set<Marker> cur = <Marker>{m1};
await tester.pumpWidget(_mapWithMarkers(prev));
diff --git a/packages/google_maps_flutter/google_maps_flutter/test/polygon_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/polygon_updates_test.dart
index 3495983..1e5ea84 100644
--- a/packages/google_maps_flutter/google_maps_flutter/test/polygon_updates_test.dart
+++ b/packages/google_maps_flutter/google_maps_flutter/test/polygon_updates_test.dart
@@ -208,8 +208,7 @@
testWidgets('Update non platform related attr', (WidgetTester tester) async {
Polygon p1 = const Polygon(polygonId: PolygonId('polygon_1'));
final Set<Polygon> prev = <Polygon>{p1};
- p1 = Polygon(
- polygonId: const PolygonId('polygon_1'), onTap: () => print(2 + 2));
+ p1 = Polygon(polygonId: const PolygonId('polygon_1'), onTap: () {});
final Set<Polygon> cur = <Polygon>{p1};
await tester.pumpWidget(_mapWithPolygons(prev));
diff --git a/packages/google_maps_flutter/google_maps_flutter/test/polyline_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/polyline_updates_test.dart
index f9d0916..4c68a71 100644
--- a/packages/google_maps_flutter/google_maps_flutter/test/polyline_updates_test.dart
+++ b/packages/google_maps_flutter/google_maps_flutter/test/polyline_updates_test.dart
@@ -202,8 +202,7 @@
testWidgets('Update non platform related attr', (WidgetTester tester) async {
Polyline p1 = const Polyline(polylineId: PolylineId('polyline_1'));
final Set<Polyline> prev = <Polyline>{p1};
- p1 = Polyline(
- polylineId: const PolylineId('polyline_1'), onTap: () => print(2 + 2));
+ p1 = Polyline(polylineId: const PolylineId('polyline_1'), onTap: () {});
final Set<Polyline> cur = <Polyline>{p1};
await tester.pumpWidget(_mapWithPolylines(prev));
diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_coordinates.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_coordinates.dart
index 185a97e..22f383b 100644
--- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_coordinates.dart
+++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_coordinates.dart
@@ -74,7 +74,7 @@
// Add a block at the bottom of this list to allow validation that the visible region of the map
// does not change when scrolled under the safe view on iOS.
// https://github.com/flutter/flutter/issues/107913
- Container(
+ const SizedBox(
width: 300,
height: 1000,
),
diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/map_coordinates.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/map_coordinates.dart
index 185a97e..22f383b 100644
--- a/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/map_coordinates.dart
+++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/map_coordinates.dart
@@ -74,7 +74,7 @@
// Add a block at the bottom of this list to allow validation that the visible region of the map
// does not change when scrolled under the safe view on iOS.
// https://github.com/flutter/flutter/issues/107913
- Container(
+ const SizedBox(
width: 300,
height: 1000,
),
diff --git a/packages/google_maps_flutter/google_maps_flutter_web/test/tests_exist_elsewhere_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/test/tests_exist_elsewhere_test.dart
index 442c501..cc32e6c 100644
--- a/packages/google_maps_flutter/google_maps_flutter_web/test/tests_exist_elsewhere_test.dart
+++ b/packages/google_maps_flutter/google_maps_flutter_web/test/tests_exist_elsewhere_test.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// ignore_for_file: avoid_print
+
import 'package:flutter_test/flutter_test.dart';
void main() {
diff --git a/packages/google_sign_in/google_sign_in/example/lib/main.dart b/packages/google_sign_in/google_sign_in/example/lib/main.dart
index 4c27543..889993b 100644
--- a/packages/google_sign_in/google_sign_in/example/lib/main.dart
+++ b/packages/google_sign_in/google_sign_in/example/lib/main.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// ignore_for_file: public_member_api_docs
+// ignore_for_file: public_member_api_docs, avoid_print
import 'dart:async';
import 'dart:convert' show json;
diff --git a/packages/google_sign_in/google_sign_in_android/example/lib/main.dart b/packages/google_sign_in/google_sign_in_android/example/lib/main.dart
index 5818b60..90d7da8 100644
--- a/packages/google_sign_in/google_sign_in_android/example/lib/main.dart
+++ b/packages/google_sign_in/google_sign_in_android/example/lib/main.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// ignore_for_file: public_member_api_docs
+// ignore_for_file: public_member_api_docs, avoid_print
import 'dart:async';
import 'dart:convert' show json;
diff --git a/packages/google_sign_in/google_sign_in_ios/example/lib/main.dart b/packages/google_sign_in/google_sign_in_ios/example/lib/main.dart
index e23935d..33deb3d 100644
--- a/packages/google_sign_in/google_sign_in_ios/example/lib/main.dart
+++ b/packages/google_sign_in/google_sign_in_ios/example/lib/main.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// ignore_for_file: public_member_api_docs
+// ignore_for_file: public_member_api_docs, avoid_print
import 'dart:async';
import 'dart:convert' show json;
diff --git a/packages/google_sign_in/google_sign_in_web/test/tests_exist_elsewhere_test.dart b/packages/google_sign_in/google_sign_in_web/test/tests_exist_elsewhere_test.dart
index 442c501..cc32e6c 100644
--- a/packages/google_sign_in/google_sign_in_web/test/tests_exist_elsewhere_test.dart
+++ b/packages/google_sign_in/google_sign_in_web/test/tests_exist_elsewhere_test.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// ignore_for_file: avoid_print
+
import 'package:flutter_test/flutter_test.dart';
void main() {
diff --git a/packages/image_picker/image_picker_for_web/test/tests_exist_elsewhere_test.dart b/packages/image_picker/image_picker_for_web/test/tests_exist_elsewhere_test.dart
index 442c501..cc32e6c 100644
--- a/packages/image_picker/image_picker_for_web/test/tests_exist_elsewhere_test.dart
+++ b/packages/image_picker/image_picker_for_web/test/tests_exist_elsewhere_test.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// ignore_for_file: avoid_print
+
import 'package:flutter_test/flutter_test.dart';
void main() {
diff --git a/packages/in_app_purchase/in_app_purchase_android/example/lib/main.dart b/packages/in_app_purchase/in_app_purchase_android/example/lib/main.dart
index 4eea725..cc612d1 100644
--- a/packages/in_app_purchase/in_app_purchase_android/example/lib/main.dart
+++ b/packages/in_app_purchase/in_app_purchase_android/example/lib/main.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// ignore_for_file: avoid_print
+
import 'dart:async';
import 'package:flutter/material.dart';
diff --git a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/in_app_purchase_storekit_platform_addition.dart b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/in_app_purchase_storekit_platform_addition.dart
index 070c138..b467b89 100644
--- a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/in_app_purchase_storekit_platform_addition.dart
+++ b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/in_app_purchase_storekit_platform_addition.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// ignore_for_file: avoid_print
+
import 'package:in_app_purchase_platform_interface/in_app_purchase_platform_interface.dart';
import '../in_app_purchase_storekit.dart';
diff --git a/packages/ios_platform_images/example/lib/main.dart b/packages/ios_platform_images/example/lib/main.dart
index 929814e..043bc69 100644
--- a/packages/ios_platform_images/example/lib/main.dart
+++ b/packages/ios_platform_images/example/lib/main.dart
@@ -22,6 +22,7 @@
super.initState();
IosPlatformImages.resolveURL('textfile')
+ // ignore: avoid_print
.then((String? value) => print(value));
}
diff --git a/packages/local_auth/local_auth/example/lib/main.dart b/packages/local_auth/local_auth/example/lib/main.dart
index 1330012..f2cded0 100644
--- a/packages/local_auth/local_auth/example/lib/main.dart
+++ b/packages/local_auth/local_auth/example/lib/main.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// ignore_for_file: public_member_api_docs
+// ignore_for_file: public_member_api_docs, avoid_print
import 'dart:async';
diff --git a/packages/local_auth/local_auth/example/lib/readme_excerpts.dart b/packages/local_auth/local_auth/example/lib/readme_excerpts.dart
index 340aaef..ccccf5c 100644
--- a/packages/local_auth/local_auth/example/lib/readme_excerpts.dart
+++ b/packages/local_auth/local_auth/example/lib/readme_excerpts.dart
@@ -5,7 +5,7 @@
// This file exists solely to host compiled excerpts for README.md, and is not
// intended for use as an actual example application.
-// ignore_for_file: public_member_api_docs
+// ignore_for_file: public_member_api_docs, avoid_print
import 'package:flutter/material.dart';
// #docregion ErrorHandling
diff --git a/packages/local_auth/local_auth_android/example/lib/main.dart b/packages/local_auth/local_auth_android/example/lib/main.dart
index 9909853..f7d908c 100644
--- a/packages/local_auth/local_auth_android/example/lib/main.dart
+++ b/packages/local_auth/local_auth_android/example/lib/main.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// ignore_for_file: public_member_api_docs
+// ignore_for_file: public_member_api_docs, avoid_print
import 'dart:async';
diff --git a/packages/local_auth/local_auth_ios/example/lib/main.dart b/packages/local_auth/local_auth_ios/example/lib/main.dart
index fdbf11f..3aa8d66 100644
--- a/packages/local_auth/local_auth_ios/example/lib/main.dart
+++ b/packages/local_auth/local_auth_ios/example/lib/main.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// ignore_for_file: public_member_api_docs
+// ignore_for_file: public_member_api_docs, avoid_print
import 'dart:async';
diff --git a/packages/local_auth/local_auth_windows/example/lib/main.dart b/packages/local_auth/local_auth_windows/example/lib/main.dart
index c7b3fd9..546b635 100644
--- a/packages/local_auth/local_auth_windows/example/lib/main.dart
+++ b/packages/local_auth/local_auth_windows/example/lib/main.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// ignore_for_file: public_member_api_docs
+// ignore_for_file: public_member_api_docs, avoid_print
import 'dart:async';
diff --git a/packages/path_provider/path_provider_linux/example/lib/main.dart b/packages/path_provider/path_provider_linux/example/lib/main.dart
index 1c7c7e8..d720146 100644
--- a/packages/path_provider/path_provider_linux/example/lib/main.dart
+++ b/packages/path_provider/path_provider_linux/example/lib/main.dart
@@ -41,29 +41,25 @@
// Platform messages may fail, so we use a try/catch PlatformException.
try {
tempDirectory = await _provider.getTemporaryPath();
- } on PlatformException catch (e, stackTrace) {
+ } on PlatformException {
tempDirectory = 'Failed to get temp directory.';
- print('$tempDirectory $e $stackTrace');
}
try {
downloadsDirectory = await _provider.getDownloadsPath();
- } on PlatformException catch (e, stackTrace) {
+ } on PlatformException {
downloadsDirectory = 'Failed to get downloads directory.';
- print('$downloadsDirectory $e $stackTrace');
}
try {
documentsDirectory = await _provider.getApplicationDocumentsPath();
- } on PlatformException catch (e, stackTrace) {
+ } on PlatformException {
documentsDirectory = 'Failed to get documents directory.';
- print('$documentsDirectory $e $stackTrace');
}
try {
appSupportDirectory = await _provider.getApplicationSupportPath();
- } on PlatformException catch (e, stackTrace) {
+ } on PlatformException {
appSupportDirectory = 'Failed to get documents directory.';
- print('$appSupportDirectory $e $stackTrace');
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
diff --git a/packages/shared_preferences/shared_preferences_linux/CHANGELOG.md b/packages/shared_preferences/shared_preferences_linux/CHANGELOG.md
index 5d59660..7c518fc 100644
--- a/packages/shared_preferences/shared_preferences_linux/CHANGELOG.md
+++ b/packages/shared_preferences/shared_preferences_linux/CHANGELOG.md
@@ -1,5 +1,6 @@
-## NEXT
+## 2.1.2
+* Updates code for stricter lint checks.
* Updates code for `no_leading_underscores_for_local_identifiers` lint.
* Updates minimum Flutter version to 2.10.
diff --git a/packages/shared_preferences/shared_preferences_linux/lib/shared_preferences_linux.dart b/packages/shared_preferences/shared_preferences_linux/lib/shared_preferences_linux.dart
index b6a9a5b..1cc1c41 100644
--- a/packages/shared_preferences/shared_preferences_linux/lib/shared_preferences_linux.dart
+++ b/packages/shared_preferences/shared_preferences_linux/lib/shared_preferences_linux.dart
@@ -7,7 +7,7 @@
import 'package:file/file.dart';
import 'package:file/local.dart';
-import 'package:flutter/foundation.dart' show visibleForTesting;
+import 'package:flutter/foundation.dart' show debugPrint, visibleForTesting;
import 'package:path/path.dart' as path;
import 'package:path_provider_linux/path_provider_linux.dart';
import 'package:shared_preferences_platform_interface/shared_preferences_platform_interface.dart';
@@ -74,7 +74,7 @@
try {
final File? localDataFile = await _getLocalDataFile();
if (localDataFile == null) {
- print('Unable to determine where to write preferences.');
+ debugPrint('Unable to determine where to write preferences.');
return false;
}
if (!localDataFile.existsSync()) {
@@ -83,7 +83,7 @@
final String stringMap = json.encode(preferences);
localDataFile.writeAsStringSync(stringMap);
} catch (e) {
- print('Error saving preferences to disk: $e');
+ debugPrint('Error saving preferences to disk: $e');
return false;
}
return true;
diff --git a/packages/shared_preferences/shared_preferences_linux/pubspec.yaml b/packages/shared_preferences/shared_preferences_linux/pubspec.yaml
index 88889dc..cd2ca80 100644
--- a/packages/shared_preferences/shared_preferences_linux/pubspec.yaml
+++ b/packages/shared_preferences/shared_preferences_linux/pubspec.yaml
@@ -2,7 +2,7 @@
description: Linux implementation of the shared_preferences plugin
repository: https://github.com/flutter/plugins/tree/main/packages/shared_preferences/shared_preferences_linux
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+shared_preferences%22
-version: 2.1.1
+version: 2.1.2
environment:
sdk: ">=2.12.0 <3.0.0"
diff --git a/packages/shared_preferences/shared_preferences_web/test/tests_exist_elsewhere_test.dart b/packages/shared_preferences/shared_preferences_web/test/tests_exist_elsewhere_test.dart
index 442c501..cc32e6c 100644
--- a/packages/shared_preferences/shared_preferences_web/test/tests_exist_elsewhere_test.dart
+++ b/packages/shared_preferences/shared_preferences_web/test/tests_exist_elsewhere_test.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// ignore_for_file: avoid_print
+
import 'package:flutter_test/flutter_test.dart';
void main() {
diff --git a/packages/shared_preferences/shared_preferences_windows/CHANGELOG.md b/packages/shared_preferences/shared_preferences_windows/CHANGELOG.md
index 935a5ee..c486a4c 100644
--- a/packages/shared_preferences/shared_preferences_windows/CHANGELOG.md
+++ b/packages/shared_preferences/shared_preferences_windows/CHANGELOG.md
@@ -1,5 +1,6 @@
-## NEXT
+## 2.1.2
+* Updates code for stricter lint checks.
* Updates code for `no_leading_underscores_for_local_identifiers` lint.
* Updates minimum Flutter version to 2.10.
diff --git a/packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart b/packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart
index a60d2ed..5cdb30c 100644
--- a/packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart
+++ b/packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart
@@ -7,7 +7,7 @@
import 'package:file/file.dart';
import 'package:file/local.dart';
-import 'package:flutter/foundation.dart' show visibleForTesting;
+import 'package:flutter/foundation.dart' show debugPrint, visibleForTesting;
import 'package:path/path.dart' as path;
import 'package:path_provider_windows/path_provider_windows.dart';
import 'package:shared_preferences_platform_interface/shared_preferences_platform_interface.dart';
@@ -80,7 +80,7 @@
try {
final File? localDataFile = await _getLocalDataFile();
if (localDataFile == null) {
- print('Unable to determine where to write preferences.');
+ debugPrint('Unable to determine where to write preferences.');
return false;
}
if (!localDataFile.existsSync()) {
@@ -89,7 +89,7 @@
final String stringMap = json.encode(preferences);
localDataFile.writeAsStringSync(stringMap);
} catch (e) {
- print('Error saving preferences to disk: $e');
+ debugPrint('Error saving preferences to disk: $e');
return false;
}
return true;
diff --git a/packages/shared_preferences/shared_preferences_windows/pubspec.yaml b/packages/shared_preferences/shared_preferences_windows/pubspec.yaml
index 032e0fb..7f97759 100644
--- a/packages/shared_preferences/shared_preferences_windows/pubspec.yaml
+++ b/packages/shared_preferences/shared_preferences_windows/pubspec.yaml
@@ -2,7 +2,7 @@
description: Windows implementation of shared_preferences
repository: https://github.com/flutter/plugins/tree/main/packages/shared_preferences/shared_preferences_windows
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+shared_preferences%22
-version: 2.1.1
+version: 2.1.2
environment:
sdk: '>=2.12.0 <3.0.0'
diff --git a/packages/url_launcher/url_launcher/example/lib/main.dart b/packages/url_launcher/url_launcher/example/lib/main.dart
index a538940..a870e18 100644
--- a/packages/url_launcher/url_launcher/example/lib/main.dart
+++ b/packages/url_launcher/url_launcher/example/lib/main.dart
@@ -196,7 +196,6 @@
onPressed: () => setState(() {
_launched = _launchInWebViewOrVC(toLaunch);
Timer(const Duration(seconds: 5), () {
- print('Closing WebView after 5 seconds...');
closeInAppWebView();
});
}),
diff --git a/packages/url_launcher/url_launcher_android/example/lib/main.dart b/packages/url_launcher/url_launcher_android/example/lib/main.dart
index 672ae4a..68cf334 100644
--- a/packages/url_launcher/url_launcher_android/example/lib/main.dart
+++ b/packages/url_launcher/url_launcher_android/example/lib/main.dart
@@ -202,7 +202,6 @@
onPressed: () => setState(() {
_launched = _launchInWebView(toLaunch);
Timer(const Duration(seconds: 5), () {
- print('Closing WebView after 5 seconds...');
launcher.closeWebView();
});
}),
diff --git a/packages/url_launcher/url_launcher_ios/example/lib/main.dart b/packages/url_launcher/url_launcher_ios/example/lib/main.dart
index 7aa3a4b..6e8ce74 100644
--- a/packages/url_launcher/url_launcher_ios/example/lib/main.dart
+++ b/packages/url_launcher/url_launcher_ios/example/lib/main.dart
@@ -226,7 +226,6 @@
onPressed: () => setState(() {
_launched = _launchInWebViewOrVC(toLaunch);
Timer(const Duration(seconds: 5), () {
- print('Closing WebView after 5 seconds...');
UrlLauncherPlatform.instance.closeWebView();
});
}),
diff --git a/packages/url_launcher/url_launcher_web/example/integration_test/link_widget_test.dart b/packages/url_launcher/url_launcher_web/example/integration_test/link_widget_test.dart
index 1447112..5f4239a 100644
--- a/packages/url_launcher/url_launcher_web/example/integration_test/link_widget_test.dart
+++ b/packages/url_launcher/url_launcher_web/example/integration_test/link_widget_test.dart
@@ -25,7 +25,7 @@
uri: uri,
target: LinkTarget.blank,
builder: (BuildContext context, FollowLink? followLink) {
- return Container(width: 100, height: 100);
+ return const SizedBox(width: 100, height: 100);
},
)),
));
@@ -43,7 +43,7 @@
uri: uri2,
target: LinkTarget.self,
builder: (BuildContext context, FollowLink? followLink) {
- return Container(width: 100, height: 100);
+ return const SizedBox(width: 100, height: 100);
},
)),
));
@@ -60,7 +60,7 @@
uri: uri3,
target: LinkTarget.self,
builder: (BuildContext context, FollowLink? followLink) {
- return Container(width: 100, height: 100);
+ return const SizedBox(width: 100, height: 100);
},
)),
));
@@ -113,7 +113,7 @@
uri: null,
target: LinkTarget.defaultTarget,
builder: (BuildContext context, FollowLink? followLink) {
- return Container(width: 100, height: 100);
+ return const SizedBox(width: 100, height: 100);
},
)),
));
diff --git a/packages/url_launcher/url_launcher_web/test/tests_exist_elsewhere_test.dart b/packages/url_launcher/url_launcher_web/test/tests_exist_elsewhere_test.dart
index 442c501..cc32e6c 100644
--- a/packages/url_launcher/url_launcher_web/test/tests_exist_elsewhere_test.dart
+++ b/packages/url_launcher/url_launcher_web/test/tests_exist_elsewhere_test.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// ignore_for_file: avoid_print
+
import 'package:flutter_test/flutter_test.dart';
void main() {
diff --git a/packages/video_player/video_player_web/test/tests_exist_elsewhere_test.dart b/packages/video_player/video_player_web/test/tests_exist_elsewhere_test.dart
index 442c501..cc32e6c 100644
--- a/packages/video_player/video_player_web/test/tests_exist_elsewhere_test.dart
+++ b/packages/video_player/video_player_web/test/tests_exist_elsewhere_test.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// ignore_for_file: avoid_print
+
import 'package:flutter_test/flutter_test.dart';
void main() {
diff --git a/packages/webview_flutter/webview_flutter/example/lib/main.dart b/packages/webview_flutter/webview_flutter/example/lib/main.dart
index 79197b0..0e71290 100644
--- a/packages/webview_flutter/webview_flutter/example/lib/main.dart
+++ b/packages/webview_flutter/webview_flutter/example/lib/main.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// ignore_for_file: public_member_api_docs
+// ignore_for_file: public_member_api_docs, avoid_print
import 'dart:async';
import 'dart:convert';
diff --git a/packages/webview_flutter/webview_flutter_android/example/lib/main.dart b/packages/webview_flutter/webview_flutter_android/example/lib/main.dart
index 4492e6e..bd958ed 100644
--- a/packages/webview_flutter/webview_flutter_android/example/lib/main.dart
+++ b/packages/webview_flutter/webview_flutter_android/example/lib/main.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// ignore_for_file: public_member_api_docs
+// ignore_for_file: public_member_api_docs, avoid_print
import 'dart:async';
import 'dart:convert';
diff --git a/packages/webview_flutter/webview_flutter_android/example/lib/web_view.dart b/packages/webview_flutter/webview_flutter_android/example/lib/web_view.dart
index 5674531..b7d98f2 100644
--- a/packages/webview_flutter/webview_flutter_android/example/lib/web_view.dart
+++ b/packages/webview_flutter/webview_flutter_android/example/lib/web_view.dart
@@ -319,10 +319,8 @@
required bool isForMainFrame,
}) async {
if (url.startsWith('https://www.youtube.com/')) {
- print('blocking navigation to $url');
return false;
}
- print('allowing navigation to $url');
return true;
}
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/lib/main.dart b/packages/webview_flutter/webview_flutter_wkwebview/example/lib/main.dart
index 3f61ebf..c1a456e 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/example/lib/main.dart
+++ b/packages/webview_flutter/webview_flutter_wkwebview/example/lib/main.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// ignore_for_file: public_member_api_docs
+// ignore_for_file: public_member_api_docs, avoid_print
import 'dart:async';
import 'dart:convert';
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/lib/web_view.dart b/packages/webview_flutter/webview_flutter_wkwebview/example/lib/web_view.dart
index c44c4e7..11edefb 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/example/lib/web_view.dart
+++ b/packages/webview_flutter/webview_flutter_wkwebview/example/lib/web_view.dart
@@ -639,10 +639,8 @@
required bool isForMainFrame,
}) async {
if (url.startsWith('https://www.youtube.com/')) {
- print('blocking navigation to $url');
return false;
}
- print('allowing navigation to $url');
return true;
}
diff --git a/script/tool/analysis_options.yaml b/script/tool/analysis_options.yaml
new file mode 100644
index 0000000..efd4017
--- /dev/null
+++ b/script/tool/analysis_options.yaml
@@ -0,0 +1,5 @@
+include: ../../analysis_options.yaml
+
+linter:
+ rules:
+ avoid_print: false # The tool is a CLI, so printing is normal