diff --git a/examples/analysis_options.yaml b/examples/analysis_options.yaml index ec6294795d2..9eb876bff40 100644 --- a/examples/analysis_options.yaml +++ b/examples/analysis_options.yaml @@ -3,7 +3,7 @@ include: package:flutter_lints/flutter.yaml analyzer: language: strict-casts: true - # strict-inference: true + strict-inference: true strict-raw-types: true errors: avoid_print: ignore @@ -35,6 +35,7 @@ linter: - prefer_const_declarations - prefer_const_literals_to_create_immutables - prefer_final_fields + - prefer_if_elements_to_conditional_expressions - prefer_relative_imports - prefer_single_quotes - simple_directive_paths @@ -51,6 +52,7 @@ linter: - unnecessary_library_directive - unnecessary_null_aware_operator_on_extension_on_nullable - unnecessary_parenthesis + - unnecessary_primary_constructor_body - unnecessary_statements - unnecessary_unawaited - unnecessary_underscores diff --git a/examples/app-architecture/offline_first/lib/data/services/api_client_service.dart b/examples/app-architecture/offline_first/lib/data/services/api_client_service.dart index 21d1b9cc641..11066361d74 100644 --- a/examples/app-architecture/offline_first/lib/data/services/api_client_service.dart +++ b/examples/app-architecture/offline_first/lib/data/services/api_client_service.dart @@ -6,7 +6,7 @@ class ApiClientService { Future getUserProfile() async { // #enddocregion ApiClientService // Simulate a network GET request - await Future.delayed(const Duration(seconds: 2)); + await Future.delayed(const Duration(seconds: 2)); // Return a dummy user profile return const UserProfile( name: 'John Doe (from API)', @@ -19,7 +19,7 @@ class ApiClientService { Future putUserProfile(UserProfile userProfile) async { // #enddocregion ApiClientService // Simulate a network PUT request - await Future.delayed(const Duration(seconds: 2)); + await Future.delayed(const Duration(seconds: 2)); // #docregion ApiClientService } } diff --git a/examples/app-architecture/offline_first/lib/data/services/database_service.dart b/examples/app-architecture/offline_first/lib/data/services/database_service.dart index 6eab3d3cae6..03de279da60 100644 --- a/examples/app-architecture/offline_first/lib/data/services/database_service.dart +++ b/examples/app-architecture/offline_first/lib/data/services/database_service.dart @@ -7,7 +7,7 @@ class DatabaseService { Future fetchUserProfile() async { // #enddocregion DatabaseService // Simulate a database select query - await Future.delayed(const Duration(milliseconds: 100)); + await Future.delayed(const Duration(milliseconds: 100)); // Return a dummy user profile return const UserProfile( name: 'John Doe (from Database)', @@ -20,7 +20,7 @@ class DatabaseService { Future updateUserProfile(UserProfile userProfile) async { // #enddocregion DatabaseService // Simulate a database update query - await Future.delayed(const Duration(milliseconds: 100)); + await Future.delayed(const Duration(milliseconds: 100)); // #docregion DatabaseService } } diff --git a/examples/app-architecture/offline_first/pubspec.yaml b/examples/app-architecture/offline_first/pubspec.yaml index 0f1c6efaff8..0848a79b0ef 100644 --- a/examples/app-architecture/offline_first/pubspec.yaml +++ b/examples/app-architecture/offline_first/pubspec.yaml @@ -13,8 +13,8 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - build_runner: ^2.15.1 - freezed: ^4.0.0 + build_runner: ^2.16.1 + freezed: ^4.0.1 flutter: uses-material-design: true diff --git a/examples/app-architecture/optimistic_state/lib/main.dart b/examples/app-architecture/optimistic_state/lib/main.dart index d71c3df74eb..ee0b00f2a87 100644 --- a/examples/app-architecture/optimistic_state/lib/main.dart +++ b/examples/app-architecture/optimistic_state/lib/main.dart @@ -80,11 +80,11 @@ class _SubscribeButtonState extends State { // #docregion listener2 /// Listen to ViewModel changes. void _onViewModelChange() { - // If the subscription action has failed + // If the subscription action has failed. if (widget.viewModel.error) { - // Reset the error state + // Reset the error state. widget.viewModel.error = false; - // Show an error message + // Show an error message. ScaffoldMessenger.of(context) .showSnackBar(const SnackBar(content: Text('Failed to subscribe'))); } @@ -105,7 +105,7 @@ class SubscribeButtonStyle { // #enddocregion style // #docregion ViewModelFull -/// Subscribe button View Model. +/// Subscribe button view model. /// Handles the subscribe action and exposes the state to the subscription. // #docregion ViewModelStart class SubscribeButtonViewModel extends ChangeNotifier { @@ -115,17 +115,17 @@ class SubscribeButtonViewModel extends ChangeNotifier { // #enddocregion ViewModelStart // #docregion States - // Whether the user is subscribed + /// Whether the user is subscribed. bool subscribed = false; - // Whether the subscription action has failed + /// Whether the subscription action has failed. bool error = false; // #enddocregion States // #docregion subscribe // Subscription action Future subscribe() async { - // Ignore taps when subscribed + // Ignore taps when subscribed. if (subscribed) { return; } @@ -133,16 +133,16 @@ class SubscribeButtonViewModel extends ChangeNotifier { // Optimistic state. // It will be reverted if the subscription fails. subscribed = true; - // Notify listeners to update the UI + // Notify listeners to update the UI. notifyListeners(); try { await subscriptionRepository.subscribe(); } catch (e) { print('Failed to subscribe: $e'); - // Revert to the previous state + // Revert to the previous state. subscribed = false; - // Set the error state + // Set the error state. error = true; } finally { notifyListeners(); @@ -157,9 +157,9 @@ class SubscribeButtonViewModel extends ChangeNotifier { class SubscriptionRepository { /// Simulates a network request and then fails. Future subscribe() async { - // Simulate a network request - await Future.delayed(const Duration(seconds: 1)); - // Fail after one second + // Simulate a network request. + await Future.delayed(const Duration(seconds: 1)); + // Fail after one second. throw Exception('Failed to subscribe'); } } diff --git a/examples/app-architecture/result/lib/main.dart b/examples/app-architecture/result/lib/main.dart index 2fb3b72cb4e..29b9acbf43d 100644 --- a/examples/app-architecture/result/lib/main.dart +++ b/examples/app-architecture/result/lib/main.dart @@ -106,7 +106,7 @@ class ApiClientService { class DatabaseService { Future> createTemporaryUser() async { - await Future.delayed(const Duration(seconds: 2)); + await Future.delayed(const Duration(seconds: 2)); return Result.ok(UserProfile('John Doe', 'john@example.com')); } } diff --git a/examples/app-architecture/result/lib/no_result.dart b/examples/app-architecture/result/lib/no_result.dart index be66f197ea7..6dd1b923ed1 100644 --- a/examples/app-architecture/result/lib/no_result.dart +++ b/examples/app-architecture/result/lib/no_result.dart @@ -108,7 +108,7 @@ class UserProfileViewModelNoTryCatch extends ChangeNotifier { class DatabaseService { Future createTemporaryUser() async { - await Future.delayed(const Duration(seconds: 2)); + await Future.delayed(const Duration(seconds: 2)); return UserProfile('John Doe', 'john@example.com'); } } diff --git a/examples/app-architecture/todo_data_service/lib/main.dart b/examples/app-architecture/todo_data_service/lib/main.dart index 2e1fdce85e5..4bb25b28439 100644 --- a/examples/app-architecture/todo_data_service/lib/main.dart +++ b/examples/app-architecture/todo_data_service/lib/main.dart @@ -18,15 +18,15 @@ import 'ui/todo_list/widgets/todo_list_screen.dart'; // #docregion MainTodo void main() { // #enddocregion MainTheme - late DatabaseService databaseService; + final DatabaseService databaseService; if (kIsWeb) { throw UnsupportedError('Platform not supported'); } else if (Platform.isLinux || Platform.isWindows || Platform.isMacOS) { - // Initialize FFI SQLite + // Initialize the FFI-based SQLite. sqfliteFfiInit(); databaseService = DatabaseService(databaseFactory: databaseFactoryFfi); } else { - // Use default native SQLite + // Use the default native SQLite. databaseService = DatabaseService(databaseFactory: databaseFactory); } diff --git a/examples/app-architecture/todo_data_service/pubspec.yaml b/examples/app-architecture/todo_data_service/pubspec.yaml index 6806da4da73..b434a1c1469 100644 --- a/examples/app-architecture/todo_data_service/pubspec.yaml +++ b/examples/app-architecture/todo_data_service/pubspec.yaml @@ -18,8 +18,8 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - build_runner: ^2.15.1 - freezed: ^4.0.0 + build_runner: ^2.16.1 + freezed: ^4.0.1 json_serializable: ^6.14.1 flutter: diff --git a/examples/cookbook/design/cupertino_sheets/lib/main.dart b/examples/cookbook/design/cupertino_sheets/lib/main.dart index 535d500d736..e0802770cde 100644 --- a/examples/cookbook/design/cupertino_sheets/lib/main.dart +++ b/examples/cookbook/design/cupertino_sheets/lib/main.dart @@ -29,7 +29,7 @@ class CupertinoSheetPage extends StatelessWidget { child: CupertinoButton.filled( onPressed: () { // #docregion ShowCupertinoSheet - showCupertinoSheet( + showCupertinoSheet( context: context, scrollableBuilder: (context, scrollController) { return SingleChildScrollView( diff --git a/examples/cookbook/forms/retrieve_input/lib/main.dart b/examples/cookbook/forms/retrieve_input/lib/main.dart index 92afe486543..f93d877bc94 100644 --- a/examples/cookbook/forms/retrieve_input/lib/main.dart +++ b/examples/cookbook/forms/retrieve_input/lib/main.dart @@ -48,7 +48,7 @@ class _MyCustomFormState extends State { // When the user presses the button, show an alert dialog containing // the text that the user has entered into the text field. onPressed: () { - showDialog( + showDialog( context: context, builder: (context) { return AlertDialog( diff --git a/examples/cookbook/forms/retrieve_input/lib/step3.dart b/examples/cookbook/forms/retrieve_input/lib/step3.dart index 30311548208..caf32d29a3c 100644 --- a/examples/cookbook/forms/retrieve_input/lib/step3.dart +++ b/examples/cookbook/forms/retrieve_input/lib/step3.dart @@ -11,8 +11,8 @@ class MyCustomForm extends StatefulWidget { // Define a corresponding State class. // This class holds the data related to the Form. class _MyCustomFormState extends State { - // Create a text controller and use it to retrieve the current value - // of the TextField. + // Create a text controller and use it to + // retrieve the current value of the TextField. final myController = TextEditingController(); @override @@ -35,12 +35,12 @@ class _MyCustomFormState extends State { // When the user presses the button, show an alert dialog containing // the text that the user has entered into the text field. onPressed: () { - showDialog( + showDialog( context: context, builder: (context) { return AlertDialog( - // Retrieve the text that the user has entered by using the - // TextEditingController. + // Retrieve the text that the user has entered by + // using the TextEditingController. content: Text(myController.text), ); }, diff --git a/examples/cookbook/games/firestore_multiplayer/pubspec.yaml b/examples/cookbook/games/firestore_multiplayer/pubspec.yaml index d0c22dc4429..23ba067ee68 100644 --- a/examples/cookbook/games/firestore_multiplayer/pubspec.yaml +++ b/examples/cookbook/games/firestore_multiplayer/pubspec.yaml @@ -10,8 +10,8 @@ dependencies: sdk: flutter async: ^2.13.1 - cloud_firestore: ^6.8.0 - firebase_core: ^4.13.0 + cloud_firestore: ^6.9.0 + firebase_core: ^4.14.0 logging: ^1.3.0 provider: ^6.1.5+1 diff --git a/examples/cookbook/images/cached_images/pubspec.yaml b/examples/cookbook/images/cached_images/pubspec.yaml index 32fd335876b..890dc66d8ba 100644 --- a/examples/cookbook/images/cached_images/pubspec.yaml +++ b/examples/cookbook/images/cached_images/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: flutter: sdk: flutter cupertino_icons: ^1.0.9 - cached_network_image: ^3.4.1 + cached_network_image: ^4.0.0 dev_dependencies: flutter_test: diff --git a/examples/cookbook/maintenance/error_reporting/pubspec.yaml b/examples/cookbook/maintenance/error_reporting/pubspec.yaml index 5833de6f291..488e21c43cb 100644 --- a/examples/cookbook/maintenance/error_reporting/pubspec.yaml +++ b/examples/cookbook/maintenance/error_reporting/pubspec.yaml @@ -9,7 +9,7 @@ environment: dependencies: flutter: sdk: flutter - sentry_flutter: ^9.27.0 + sentry_flutter: ^9.28.0 dev_dependencies: flutter_test: diff --git a/examples/cookbook/networking/background_parsing/lib/main.dart b/examples/cookbook/networking/background_parsing/lib/main.dart index d83d1df56ae..938ededba2d 100644 --- a/examples/cookbook/networking/background_parsing/lib/main.dart +++ b/examples/cookbook/networking/background_parsing/lib/main.dart @@ -39,7 +39,7 @@ class Photo { required this.thumbnailUrl, }); - factory Photo.fromJson(Map json) { + factory Photo.fromJson(Map json) { return Photo( albumId: json['albumId'] as int, id: json['id'] as int, diff --git a/examples/cookbook/networking/background_parsing/lib/main_step3.dart b/examples/cookbook/networking/background_parsing/lib/main_step3.dart index a9f2d52613e..3f14d65b0a2 100644 --- a/examples/cookbook/networking/background_parsing/lib/main_step3.dart +++ b/examples/cookbook/networking/background_parsing/lib/main_step3.dart @@ -38,7 +38,7 @@ class Photo { required this.thumbnailUrl, }); - factory Photo.fromJson(Map json) { + factory Photo.fromJson(Map json) { return Photo( albumId: json['albumId'] as int, id: json['id'] as int, diff --git a/examples/cookbook/persistence/reading_writing_files/lib/main.dart b/examples/cookbook/persistence/reading_writing_files/lib/main.dart index 9de5db1db57..7fd47c9947f 100644 --- a/examples/cookbook/persistence/reading_writing_files/lib/main.dart +++ b/examples/cookbook/persistence/reading_writing_files/lib/main.dart @@ -10,7 +10,7 @@ import 'package:path_provider/path_provider.dart'; void main() { runApp( MaterialApp( - title: 'Reading and Writing Files', + title: 'Reading and writing files', home: FlutterDemo(storage: CounterStorage()), ), ); @@ -37,12 +37,12 @@ class CounterStorage { try { final file = await _localFile; - // Read the file + // Read the contents of the local file. final contents = await file.readAsString(); return int.parse(contents); - } catch (e) { - // If encountering an error, return 0 + } catch (_) { + // If an error was encountered, return 0. return 0; } } @@ -52,7 +52,7 @@ class CounterStorage { Future writeCounter(int counter) async { final file = await _localFile; - // Write the file + // Write the counter as a string to the file. return file.writeAsString('$counter'); } // #enddocregion writeCounter @@ -92,7 +92,7 @@ class _FlutterDemoState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: const Text('Reading and Writing Files')), + appBar: AppBar(title: const Text('Reading and writing files')), body: Center( child: Text('Button tapped $_counter time${_counter == 1 ? '' : 's'}.'), ), diff --git a/examples/cookbook/plugins/google_mobile_ads/lib/main.dart b/examples/cookbook/plugins/google_mobile_ads/lib/main.dart index 06bf273227c..7fb5a4c812f 100644 --- a/examples/cookbook/plugins/google_mobile_ads/lib/main.dart +++ b/examples/cookbook/plugins/google_mobile_ads/lib/main.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; // #docregion main -void main() async { +void main() { WidgetsFlutterBinding.ensureInitialized(); unawaited(MobileAds.instance.initialize()); diff --git a/examples/cookbook/testing/integration/introduction/pubspec.yaml b/examples/cookbook/testing/integration/introduction/pubspec.yaml index 68d4c067610..d3ba9ed536f 100644 --- a/examples/cookbook/testing/integration/introduction/pubspec.yaml +++ b/examples/cookbook/testing/integration/introduction/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: sdk: flutter dev_dependencies: - test: ^1.31.0 + test: ^1.31.1 flutter: uses-material-design: true diff --git a/examples/cookbook/testing/unit/counter_app/pubspec.yaml b/examples/cookbook/testing/unit/counter_app/pubspec.yaml index a9c3f000342..5678a091771 100644 --- a/examples/cookbook/testing/unit/counter_app/pubspec.yaml +++ b/examples/cookbook/testing/unit/counter_app/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: flutter: sdk: flutter cupertino_icons: ^1.0.9 - test: ^1.31.0 + test: ^1.31.1 flutter: uses-material-design: true diff --git a/examples/cookbook/testing/unit/mocking/pubspec.yaml b/examples/cookbook/testing/unit/mocking/pubspec.yaml index 0143517a161..9a945c69203 100644 --- a/examples/cookbook/testing/unit/mocking/pubspec.yaml +++ b/examples/cookbook/testing/unit/mocking/pubspec.yaml @@ -16,7 +16,7 @@ dev_dependencies: flutter_test: sdk: flutter mockito: ^5.8.1 - build_runner: ^2.15.1 + build_runner: ^2.16.1 flutter: uses-material-design: true diff --git a/examples/cookbook/testing/widget/orientation_tests/pubspec.yaml b/examples/cookbook/testing/widget/orientation_tests/pubspec.yaml index 81800c296ba..2be5a349dce 100644 --- a/examples/cookbook/testing/widget/orientation_tests/pubspec.yaml +++ b/examples/cookbook/testing/widget/orientation_tests/pubspec.yaml @@ -9,7 +9,7 @@ environment: dependencies: flutter: sdk: flutter - path_provider: ^2.1.5 + path_provider: ^2.1.6 path: ^1.9.1 flutter_test: sdk: flutter diff --git a/examples/data-and-backend/json/pubspec.yaml b/examples/data-and-backend/json/pubspec.yaml index 113feac60c3..8b0cca48a4d 100644 --- a/examples/data-and-backend/json/pubspec.yaml +++ b/examples/data-and-backend/json/pubspec.yaml @@ -12,5 +12,5 @@ dependencies: json_annotation: ^4.12.0 dev_dependencies: - build_runner: ^2.15.1 + build_runner: ^2.16.1 json_serializable: ^6.14.1 diff --git a/examples/get-started/flutter-for/android_devs/analysis_options.yaml b/examples/get-started/flutter-for/android_devs/analysis_options.yaml deleted file mode 100644 index e2badd73ea0..00000000000 --- a/examples/get-started/flutter-for/android_devs/analysis_options.yaml +++ /dev/null @@ -1 +0,0 @@ -include: ../../../analysis_options.yaml diff --git a/examples/get-started/flutter-for/ios_devs/lib/form.dart b/examples/get-started/flutter-for/ios_devs/lib/form.dart index dfae2a464cc..a4da6ae1dc5 100644 --- a/examples/get-started/flutter-for/ios_devs/lib/form.dart +++ b/examples/get-started/flutter-for/ios_devs/lib/form.dart @@ -45,7 +45,7 @@ class _MyFormState extends State { // When the user presses the button, show an alert dialog with the // text the user has typed into our text field. onPressed: () { - showDialog( + showDialog( context: context, builder: (context) { return AlertDialog( diff --git a/examples/get-started/flutter-for/react_native_devs/lib/examples.dart b/examples/get-started/flutter-for/react_native_devs/lib/examples.dart index 0169d333fef..55c62d8988c 100644 --- a/examples/get-started/flutter-for/react_native_devs/lib/examples.dart +++ b/examples/get-started/flutter-for/react_native_devs/lib/examples.dart @@ -365,7 +365,7 @@ class _TextEditingExampleState extends State { ElevatedButton( child: const Text('Submit'), onPressed: () { - showDialog( + showDialog( context: context, builder: (context) { return AlertDialog( @@ -399,7 +399,7 @@ class _FormExampleState extends State { final form = formKey.currentState; if (form != null && form.validate()) { form.save(); - showDialog( + showDialog( context: context, builder: (context) { return AlertDialog( diff --git a/examples/get-started/flutter-for/react_native_devs/lib/futures.dart b/examples/get-started/flutter-for/react_native_devs/lib/futures.dart index 54d17c99745..d2c4c0a0ccc 100644 --- a/examples/get-started/flutter-for/react_native_devs/lib/futures.dart +++ b/examples/get-started/flutter-for/react_native_devs/lib/futures.dart @@ -18,5 +18,5 @@ void main() { example ._getIPAddress() .then((ip) => print(ip)) - .catchError((error) => print(error)); + .onError((error, _) => print(error)); } diff --git a/examples/get-started/flutter-for/react_native_devs/lib/main.dart b/examples/get-started/flutter-for/react_native_devs/lib/main.dart index 6bb6c9c6b4d..d30dc1af628 100644 --- a/examples/get-started/flutter-for/react_native_devs/lib/main.dart +++ b/examples/get-started/flutter-for/react_native_devs/lib/main.dart @@ -1,4 +1,6 @@ -// ignore_for_file: avoid_print, unused_local_variable, prefer_typing_uninitialized_variables +// ignore_for_file: avoid_print, unused_local_variable +// ignore_for_file: inference_failure_on_uninitialized_variable +// ignore_for_file: prefer_typing_uninitialized_variables // #docregion main /// Dart diff --git a/examples/get-started/flutter-for/xamarin_devs/lib/form.dart b/examples/get-started/flutter-for/xamarin_devs/lib/form.dart index d036cdb60b8..b8c046809f8 100644 --- a/examples/get-started/flutter-for/xamarin_devs/lib/form.dart +++ b/examples/get-started/flutter-for/xamarin_devs/lib/form.dart @@ -31,7 +31,7 @@ class _MyFormState extends State { // When the user presses the button, show an alert dialog with the // text that the user has typed into our text field. onPressed: () { - showDialog( + showDialog( context: context, builder: (context) { return AlertDialog( diff --git a/examples/integration_test/pubspec.yaml b/examples/integration_test/pubspec.yaml index aa66353f481..2a8f0dd3ed7 100644 --- a/examples/integration_test/pubspec.yaml +++ b/examples/integration_test/pubspec.yaml @@ -17,7 +17,7 @@ dev_dependencies: sdk: flutter flutter_driver: sdk: flutter - test: ^1.31.0 + test: ^1.31.1 flutter: uses-material-design: true diff --git a/examples/integration_test_migration/pubspec.yaml b/examples/integration_test_migration/pubspec.yaml index 99f7d4a1673..e63b1b9e2b7 100644 --- a/examples/integration_test_migration/pubspec.yaml +++ b/examples/integration_test_migration/pubspec.yaml @@ -19,7 +19,7 @@ dev_dependencies: sdk: flutter flutter_driver: sdk: flutter - test: ^1.31.0 + test: ^1.31.1 flutter: uses-material-design: true diff --git a/examples/internationalization/add_language/lib/nn_intl.dart b/examples/internationalization/add_language/lib/nn_intl.dart index d02e162fa70..905a7a47d91 100644 --- a/examples/internationalization/add_language/lib/nn_intl.dart +++ b/examples/internationalization/add_language/lib/nn_intl.dart @@ -223,7 +223,7 @@ class _NnMaterialLocalizationsDelegate bool isSupported(Locale locale) => locale.languageCode == 'nn'; @override - Future load(Locale locale) async { + Future load(Locale locale) { final String localeName = intl.Intl.canonicalizedLocale(locale.toString()); // The locale (in this case `nn`) needs to be initialized into the custom diff --git a/examples/internationalization/add_language/pubspec.yaml b/examples/internationalization/add_language/pubspec.yaml index 314c26a477c..beb42d75200 100644 --- a/examples/internationalization/add_language/pubspec.yaml +++ b/examples/internationalization/add_language/pubspec.yaml @@ -10,7 +10,7 @@ dependencies: sdk: flutter flutter_localizations: sdk: flutter - intl: any # Use the pinned version from flutter_localizations + intl: any # Use the pinned version from flutter_localizations. dev_dependencies: flutter_test: diff --git a/examples/internationalization/intl_example/pubspec.yaml b/examples/internationalization/intl_example/pubspec.yaml index bace6381db4..d27b3659f47 100644 --- a/examples/internationalization/intl_example/pubspec.yaml +++ b/examples/internationalization/intl_example/pubspec.yaml @@ -10,13 +10,13 @@ dependencies: sdk: flutter flutter_localizations: sdk: flutter - intl: any # Use the pinned version from flutter_localizations + intl: any # Use the pinned version from flutter_localizations. dev_dependencies: flutter_test: sdk: flutter # TODO(parlough): Add back when analyzer constraints allow. - # intl_translation: ^0.20.1 + # intl_translation: ^0.22.0 flutter: uses-material-design: true diff --git a/examples/perf/concurrency/isolates/lib/main.dart b/examples/perf/concurrency/isolates/lib/main.dart index 4365bf4606a..16d0c4e66e8 100644 --- a/examples/perf/concurrency/isolates/lib/main.dart +++ b/examples/perf/concurrency/isolates/lib/main.dart @@ -56,7 +56,7 @@ class Photo { required this.thumbnailUrl, }); - factory Photo.fromJson(Map data) { + factory Photo.fromJson(Map data) { return Photo( albumId: data['albumId'] as int, id: data['id'] as int, diff --git a/examples/perf/deferred_components/pubspec.yaml b/examples/perf/deferred_components/pubspec.yaml index 71a99ca6a1f..b91f4e08078 100644 --- a/examples/perf/deferred_components/pubspec.yaml +++ b/examples/perf/deferred_components/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - test: ^1.31.0 + test: ^1.31.1 flutter: uses-material-design: true diff --git a/examples/resources/dart_swift_concurrency/lib/async_weather.dart b/examples/resources/dart_swift_concurrency/lib/async_weather.dart index bd15794aa46..15f77f56360 100644 --- a/examples/resources/dart_swift_concurrency/lib/async_weather.dart +++ b/examples/resources/dart_swift_concurrency/lib/async_weather.dart @@ -22,7 +22,7 @@ enum Weather { rainy, windy, sunny } class HomePageViewModel { const HomePageViewModel(); Future load() async { - await Future.delayed(const Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 1)); return Weather.sunny; } } diff --git a/examples/state_mgmt/simple/pubspec.yaml b/examples/state_mgmt/simple/pubspec.yaml index 32e8b6c5452..8206fdd8fac 100644 --- a/examples/state_mgmt/simple/pubspec.yaml +++ b/examples/state_mgmt/simple/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - test: ^1.31.0 + test: ^1.31.1 flutter: uses-material-design: true diff --git a/examples/testing/common_errors/lib/set_state_build.dart b/examples/testing/common_errors/lib/set_state_build.dart index 027a7d47439..28a798bf851 100644 --- a/examples/testing/common_errors/lib/set_state_build.dart +++ b/examples/testing/common_errors/lib/set_state_build.dart @@ -7,7 +7,7 @@ class ProblemWidget extends StatelessWidget { // #docregion problem Widget build(BuildContext context) { // Don't do this. - showDialog( + showDialog( context: context, builder: (context) { return const AlertDialog(title: Text('Alert Dialog')); @@ -38,7 +38,7 @@ class FirstScreen extends StatelessWidget { // Immediately show a dialog upon loading the second screen. Navigator.push( context, - PageRouteBuilder( + PageRouteBuilder( barrierDismissible: true, opaque: false, pageBuilder: (_, anim1, anim2) => const MyDialog(), diff --git a/examples/testing/errors/pubspec.yaml b/examples/testing/errors/pubspec.yaml index 861dfc92d8a..4256c523504 100644 --- a/examples/testing/errors/pubspec.yaml +++ b/examples/testing/errors/pubspec.yaml @@ -9,7 +9,7 @@ environment: dependencies: flutter: sdk: flutter - firebase_core: ^4.9.0 + firebase_core: ^4.14.0 dev_dependencies: integration_test: diff --git a/sites/docs/src/content/app-architecture/design-patterns/optimistic-state.md b/sites/docs/src/content/app-architecture/design-patterns/optimistic-state.md index b3053215806..28ad89c7e96 100644 --- a/sites/docs/src/content/app-architecture/design-patterns/optimistic-state.md +++ b/sites/docs/src/content/app-architecture/design-patterns/optimistic-state.md @@ -154,9 +154,9 @@ to the `SubscriptionRepository` with the following code: class SubscriptionRepository { /// Simulates a network request and then fails. Future subscribe() async { - // Simulate a network request - await Future.delayed(const Duration(seconds: 1)); - // Fail after one second + // Simulate a network request. + await Future.delayed(const Duration(seconds: 1)); + // Fail after one second. throw Exception('Failed to subscribe'); } } @@ -178,10 +178,10 @@ add the following public members to the `SubscribeButtonViewModel`: ```dart -// Whether the user is subscribed +/// Whether the user is subscribed. bool subscribed = false; -// Whether the subscription action has failed +/// Whether the subscription action has failed. bool error = false; ``` @@ -202,7 +202,7 @@ Next, implement an asynchronous `subscribe()` method: ```dart // Subscription action Future subscribe() async { - // Ignore taps when subscribed + // Ignore taps when subscribed. if (subscribed) { return; } @@ -210,16 +210,16 @@ Future subscribe() async { // Optimistic state. // It will be reverted if the subscription fails. subscribed = true; - // Notify listeners to update the UI + // Notify listeners to update the UI. notifyListeners(); try { await subscriptionRepository.subscribe(); } catch (e) { print('Failed to subscribe: $e'); - // Revert to the previous state + // Revert to the previous state. subscribed = false; - // Set the error state + // Set the error state. error = true; } finally { notifyListeners(); @@ -247,22 +247,22 @@ The complete `SubscribeButtonViewModel` should look like this: ```dart -/// Subscribe button View Model. +/// Subscribe button view model. /// Handles the subscribe action and exposes the state to the subscription. class SubscribeButtonViewModel extends ChangeNotifier { SubscribeButtonViewModel({required this.subscriptionRepository}); final SubscriptionRepository subscriptionRepository; - // Whether the user is subscribed + /// Whether the user is subscribed. bool subscribed = false; - // Whether the subscription action has failed + /// Whether the subscription action has failed. bool error = false; // Subscription action Future subscribe() async { - // Ignore taps when subscribed + // Ignore taps when subscribed. if (subscribed) { return; } @@ -270,16 +270,16 @@ class SubscribeButtonViewModel extends ChangeNotifier { // Optimistic state. // It will be reverted if the subscription fails. subscribed = true; - // Notify listeners to update the UI + // Notify listeners to update the UI. notifyListeners(); try { await subscriptionRepository.subscribe(); } catch (e) { print('Failed to subscribe: $e'); - // Revert to the previous state + // Revert to the previous state. subscribed = false; - // Set the error state + // Set the error state. error = true; } finally { notifyListeners(); @@ -372,11 +372,11 @@ void dispose() { ```dart /// Listen to ViewModel changes. void _onViewModelChange() { - // If the subscription action has failed + // If the subscription action has failed. if (widget.viewModel.error) { - // Reset the error state + // Reset the error state. widget.viewModel.error = false; - // Show an error message + // Show an error message. ScaffoldMessenger.of(context) .showSnackBar(const SnackBar(content: Text('Failed to subscribe'))); } @@ -503,11 +503,11 @@ class _SubscribeButtonState extends State { /// Listen to ViewModel changes. void _onViewModelChange() { - // If the subscription action has failed + // If the subscription action has failed. if (widget.viewModel.error) { - // Reset the error state + // Reset the error state. widget.viewModel.error = false; - // Show an error message + // Show an error message. ScaffoldMessenger.of(context) .showSnackBar(const SnackBar(content: Text('Failed to subscribe'))); } @@ -524,22 +524,22 @@ class SubscribeButtonStyle { ); } -/// Subscribe button View Model. +/// Subscribe button view model. /// Handles the subscribe action and exposes the state to the subscription. class SubscribeButtonViewModel extends ChangeNotifier { SubscribeButtonViewModel({required this.subscriptionRepository}); final SubscriptionRepository subscriptionRepository; - // Whether the user is subscribed + /// Whether the user is subscribed. bool subscribed = false; - // Whether the subscription action has failed + /// Whether the subscription action has failed. bool error = false; // Subscription action Future subscribe() async { - // Ignore taps when subscribed + // Ignore taps when subscribed. if (subscribed) { return; } @@ -547,16 +547,16 @@ class SubscribeButtonViewModel extends ChangeNotifier { // Optimistic state. // It will be reverted if the subscription fails. subscribed = true; - // Notify listeners to update the UI + // Notify listeners to update the UI. notifyListeners(); try { await subscriptionRepository.subscribe(); } catch (e) { print('Failed to subscribe: $e'); - // Revert to the previous state + // Revert to the previous state. subscribed = false; - // Set the error state + // Set the error state. error = true; } finally { notifyListeners(); @@ -568,9 +568,9 @@ class SubscribeButtonViewModel extends ChangeNotifier { class SubscriptionRepository { /// Simulates a network request and then fails. Future subscribe() async { - // Simulate a network request - await Future.delayed(const Duration(seconds: 1)); - // Fail after one second + // Simulate a network request. + await Future.delayed(const Duration(seconds: 1)); + // Fail after one second. throw Exception('Failed to subscribe'); } } diff --git a/sites/docs/src/content/app-architecture/design-patterns/sql.md b/sites/docs/src/content/app-architecture/design-patterns/sql.md index f205946e62b..3b88338bee8 100644 --- a/sites/docs/src/content/app-architecture/design-patterns/sql.md +++ b/sites/docs/src/content/app-architecture/design-patterns/sql.md @@ -437,15 +437,15 @@ which is itself passed into the `MainApp` as a constructor argument dependency. ```dart void main() { - late DatabaseService databaseService; + final DatabaseService databaseService; if (kIsWeb) { throw UnsupportedError('Platform not supported'); } else if (Platform.isLinux || Platform.isWindows || Platform.isMacOS) { - // Initialize FFI SQLite + // Initialize the FFI-based SQLite. sqfliteFfiInit(); databaseService = DatabaseService(databaseFactory: databaseFactoryFfi); } else { - // Use default native SQLite + // Use the default native SQLite. databaseService = DatabaseService(databaseFactory: databaseFactory); } diff --git a/sites/docs/src/content/cookbook/design/cupertino-sheets.md b/sites/docs/src/content/cookbook/design/cupertino-sheets.md index 0b00b9d8db3..95cc35c831f 100644 --- a/sites/docs/src/content/cookbook/design/cupertino-sheets.md +++ b/sites/docs/src/content/cookbook/design/cupertino-sheets.md @@ -47,7 +47,7 @@ that returns the content for the sheet, such as a `SingleChildScrollView`. ```dart -showCupertinoSheet( +showCupertinoSheet( context: context, scrollableBuilder: (context, scrollController) { return SingleChildScrollView( @@ -106,7 +106,7 @@ class CupertinoSheetPage extends StatelessWidget { child: Center( child: CupertinoButton.filled( onPressed: () { - showCupertinoSheet( + showCupertinoSheet( context: context, scrollableBuilder: (context, scrollController) { return SingleChildScrollView( diff --git a/sites/docs/src/content/cookbook/forms/retrieve-input.md b/sites/docs/src/content/cookbook/forms/retrieve-input.md index 8316a35267f..1c5f9f00961 100644 --- a/sites/docs/src/content/cookbook/forms/retrieve-input.md +++ b/sites/docs/src/content/cookbook/forms/retrieve-input.md @@ -82,12 +82,12 @@ FloatingActionButton( // When the user presses the button, show an alert dialog containing // the text that the user has entered into the text field. onPressed: () { - showDialog( + showDialog( context: context, builder: (context) { return AlertDialog( - // Retrieve the text that the user has entered by using the - // TextEditingController. + // Retrieve the text that the user has entered by + // using the TextEditingController. content: Text(myController.text), ); }, @@ -152,7 +152,7 @@ class _MyCustomFormState extends State { // When the user presses the button, show an alert dialog containing // the text that the user has entered into the text field. onPressed: () { - showDialog( + showDialog( context: context, builder: (context) { return AlertDialog( diff --git a/sites/docs/src/content/cookbook/networking/background-parsing.md b/sites/docs/src/content/cookbook/networking/background-parsing.md index cb0b79a3843..c78a4bedb4f 100644 --- a/sites/docs/src/content/cookbook/networking/background-parsing.md +++ b/sites/docs/src/content/cookbook/networking/background-parsing.md @@ -86,7 +86,7 @@ class Photo { required this.thumbnailUrl, }); - factory Photo.fromJson(Map json) { + factory Photo.fromJson(Map json) { return Photo( albumId: json['albumId'] as int, id: json['id'] as int, @@ -210,7 +210,7 @@ class Photo { required this.thumbnailUrl, }); - factory Photo.fromJson(Map json) { + factory Photo.fromJson(Map json) { return Photo( albumId: json['albumId'] as int, id: json['id'] as int, diff --git a/sites/docs/src/content/cookbook/persistence/reading-writing-files.md b/sites/docs/src/content/cookbook/persistence/reading-writing-files.md index 6eb70f06042..d8a102f2e65 100644 --- a/sites/docs/src/content/cookbook/persistence/reading-writing-files.md +++ b/sites/docs/src/content/cookbook/persistence/reading-writing-files.md @@ -96,7 +96,7 @@ file as a string using the `'$counter'` syntax. Future writeCounter(int counter) async { final file = await _localFile; - // Write the file + // Write the counter as a string to the file. return file.writeAsString('$counter'); } ``` @@ -112,12 +112,12 @@ Future readCounter() async { try { final file = await _localFile; - // Read the file + // Read the contents of the local file. final contents = await file.readAsString(); return int.parse(contents); - } catch (e) { - // If encountering an error, return 0 + } catch (_) { + // If an error was encountered, return 0. return 0; } } @@ -136,7 +136,7 @@ import 'package:path_provider/path_provider.dart'; void main() { runApp( MaterialApp( - title: 'Reading and Writing Files', + title: 'Reading and writing files', home: FlutterDemo(storage: CounterStorage()), ), ); @@ -158,12 +158,12 @@ class CounterStorage { try { final file = await _localFile; - // Read the file + // Read the contents of the local file. final contents = await file.readAsString(); return int.parse(contents); - } catch (e) { - // If encountering an error, return 0 + } catch (_) { + // If an error was encountered, return 0. return 0; } } @@ -171,7 +171,7 @@ class CounterStorage { Future writeCounter(int counter) async { final file = await _localFile; - // Write the file + // Write the counter as a string to the file. return file.writeAsString('$counter'); } } @@ -210,7 +210,7 @@ class _FlutterDemoState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: const Text('Reading and Writing Files')), + appBar: AppBar(title: const Text('Reading and writing files')), body: Center( child: Text('Button tapped $_counter time${_counter == 1 ? '' : 's'}.'), ), diff --git a/sites/docs/src/content/cookbook/plugins/google-mobile-ads.md b/sites/docs/src/content/cookbook/plugins/google-mobile-ads.md index d4c8b1e9d8a..4110078c87e 100644 --- a/sites/docs/src/content/cookbook/plugins/google-mobile-ads.md +++ b/sites/docs/src/content/cookbook/plugins/google-mobile-ads.md @@ -146,7 +146,7 @@ You need to initialize the Mobile Ads SDK before loading ads. ```dart - void main() async { + void main() { WidgetsFlutterBinding.ensureInitialized(); unawaited(MobileAds.instance.initialize()); diff --git a/sites/docs/src/content/flutter-for/dart-swift-concurrency.md b/sites/docs/src/content/flutter-for/dart-swift-concurrency.md index fc44bab3c68..e9417809180 100644 --- a/sites/docs/src/content/flutter-for/dart-swift-concurrency.md +++ b/sites/docs/src/content/flutter-for/dart-swift-concurrency.md @@ -175,7 +175,7 @@ returns a `Future` object: class HomePageViewModel { const HomePageViewModel(); Future load() async { - await Future.delayed(const Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 1)); return Weather.sunny; } } diff --git a/sites/docs/src/content/flutter-for/react-native-devs.md b/sites/docs/src/content/flutter-for/react-native-devs.md index f35ccc3ee2b..d9e1395cdc3 100644 --- a/sites/docs/src/content/flutter-for/react-native-devs.md +++ b/sites/docs/src/content/flutter-for/react-native-devs.md @@ -252,7 +252,7 @@ void main() { example ._getIPAddress() .then((ip) => print(ip)) - .catchError((error) => print(error)); + .onError((error, _) => print(error)); } ``` @@ -2070,7 +2070,7 @@ Widget build(BuildContext context) { ElevatedButton( child: const Text('Submit'), onPressed: () { - showDialog( + showDialog( context: context, builder: (context) { return AlertDialog( @@ -2147,7 +2147,7 @@ void _submit() { final form = formKey.currentState; if (form != null && form.validate()) { form.save(); - showDialog( + showDialog( context: context, builder: (context) { return AlertDialog( diff --git a/sites/docs/src/content/flutter-for/uikit-devs.md b/sites/docs/src/content/flutter-for/uikit-devs.md index 72f3238e0cc..1afd4249f42 100644 --- a/sites/docs/src/content/flutter-for/uikit-devs.md +++ b/sites/docs/src/content/flutter-for/uikit-devs.md @@ -1503,7 +1503,7 @@ class _MyFormState extends State { // When the user presses the button, show an alert dialog with the // text the user has typed into our text field. onPressed: () { - showDialog( + showDialog( context: context, builder: (context) { return AlertDialog( diff --git a/sites/docs/src/content/flutter-for/xamarin-forms-devs.md b/sites/docs/src/content/flutter-for/xamarin-forms-devs.md index 5026c0ccc08..743dd63b1df 100644 --- a/sites/docs/src/content/flutter-for/xamarin-forms-devs.md +++ b/sites/docs/src/content/flutter-for/xamarin-forms-devs.md @@ -2167,7 +2167,7 @@ class _MyFormState extends State { // When the user presses the button, show an alert dialog with the // text that the user has typed into our text field. onPressed: () { - showDialog( + showDialog( context: context, builder: (context) { return AlertDialog( diff --git a/sites/docs/src/content/testing/common-errors.md b/sites/docs/src/content/testing/common-errors.md index d11f2ef3696..55670ea1d09 100644 --- a/sites/docs/src/content/testing/common-errors.md +++ b/sites/docs/src/content/testing/common-errors.md @@ -425,7 +425,7 @@ The following snippet seems to be a common culprit of this error: ```dart Widget build(BuildContext context) { // Don't do this. - showDialog( + showDialog( context: context, builder: (context) { return const AlertDialog(title: Text('Alert Dialog')); @@ -473,7 +473,7 @@ class FirstScreen extends StatelessWidget { // Immediately show a dialog upon loading the second screen. Navigator.push( context, - PageRouteBuilder( + PageRouteBuilder( barrierDismissible: true, opaque: false, pageBuilder: (_, anim1, anim2) => const MyDialog(), diff --git a/sites/docs/src/content/ui/internationalization/index.md b/sites/docs/src/content/ui/internationalization/index.md index 95b70a91a10..aeed5c6925c 100644 --- a/sites/docs/src/content/ui/internationalization/index.md +++ b/sites/docs/src/content/ui/internationalization/index.md @@ -1108,7 +1108,7 @@ class _NnMaterialLocalizationsDelegate bool isSupported(Locale locale) => locale.languageCode == 'nn'; @override - Future load(Locale locale) async { + Future load(Locale locale) { final String localeName = intl.Intl.canonicalizedLocale(locale.toString()); // The locale (in this case `nn`) needs to be initialized into the custom