Sync lints and fix offenders (#308)

diff --git a/analysis_options.yaml b/analysis_options.yaml
index 69b3fab..6671951 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -7,9 +7,6 @@
 # See the configuration guide for more
 # https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
 #
-# This file contains the analysis options used by Flutter tools, such as
-# IntelliJ, Android Studio, and the 'flutter analyze' command.
-#
 # This file is derived from the master file in the flutter repo, and should be
 # kept in sync with it.
 
@@ -23,8 +20,8 @@
     missing_return: warning
     # allow having TODOs in the code
     todo: ignore
-  exclude:
-    - 'flutter/**'
+    # Turned off until null-safe rollout is complete.
+    unnecessary_null_comparison: ignore
 
 linter:
   rules:
@@ -36,15 +33,18 @@
     # - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
     - always_require_non_null_named_parameters
     - always_specify_types
+    # - always_use_package_imports # we do this commonly
     - annotate_overrides
     # - avoid_annotating_with_dynamic # conflicts with always_specify_types
-    # - avoid_as # no longer relevant with null safety
     - avoid_bool_literals_in_conditional_expressions
     # - avoid_catches_without_on_clauses # we do this commonly
     # - avoid_catching_errors # we do this commonly
     - avoid_classes_with_only_static_members
     # - avoid_double_and_int_checks # only useful when targeting JS runtime
+    # - avoid_dynamic_calls # not yet tested
     - avoid_empty_else
+    - avoid_equals_and_hash_code_on_mutable_classes
+    # - avoid_escaping_inner_quotes # not yet tested
     - avoid_field_initializers_in_const_classes
     - avoid_function_literals_in_foreach_calls
     # - avoid_implementing_value_types # not yet tested
@@ -52,7 +52,9 @@
     # - avoid_js_rounded_ints # only useful when targeting JS runtime
     - avoid_null_checks_in_equality_operators
     # - avoid_positional_boolean_parameters # not yet tested
+    # - avoid_print # not yet tested
     # - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
+    # - avoid_redundant_argument_values # not yet tested
     - avoid_relative_lib_imports
     - avoid_renaming_method_parameters
     - avoid_return_types_on_setters
@@ -61,43 +63,57 @@
     - avoid_returning_null_for_void
     # - avoid_returning_this # there are plenty of valid reasons to return this
     # - avoid_setters_without_getters # not yet tested
-    # - avoid_shadowing_type_parameters # not yet tested
-    # - avoid_single_cascade_in_expression_statements # not yet tested
+    - avoid_shadowing_type_parameters
+    - avoid_single_cascade_in_expression_statements
     - avoid_slow_async_io
+    - avoid_type_to_string
     - avoid_types_as_parameter_names
     # - avoid_types_on_closure_parameters # conflicts with always_specify_types
+    - avoid_unnecessary_containers
     - avoid_unused_constructor_parameters
     - avoid_void_async
+    # - avoid_web_libraries_in_flutter # not yet tested
     - await_only_futures
+    - camel_case_extensions
     - camel_case_types
     - cancel_subscriptions
     # - cascade_invocations # not yet tested
+    - cast_nullable_to_non_nullable
     # - close_sinks # not reliable enough
-    # - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
+    # - comment_references # blocked on https://github.com/dart-lang/linter/issues/1142
     # - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
     - control_flow_in_finally
-    # - curly_braces_in_flow_control_structures # not yet tested
+    # - curly_braces_in_flow_control_structures # not required by flutter style
+    - deprecated_consistency
     # - diagnostic_describe_all_properties # not yet tested
     - directives_ordering
+    # - do_not_use_environment # we do this commonly
     - empty_catches
     - empty_constructor_bodies
     - empty_statements
-    # - file_names # not yet tested
+    - exhaustive_cases
+    - file_names
     - flutter_style_todos
     - hash_and_equals
     - implementation_imports
     # - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
     - iterable_contains_unrelated_type
-    # - join_return_with_assignment # not yet tested
+    # - join_return_with_assignment # not required by flutter style
+    - leading_newlines_in_multiline_strings
     - library_names
     - library_prefixes
-    # - lines_longer_than_80_chars # not yet tested
+    # - lines_longer_than_80_chars # not required by flutter style
     - list_remove_unrelated_type
     # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
+    - missing_whitespace_between_adjacent_strings
     - no_adjacent_strings_in_list
+    # - no_default_cases # too many false positives
     - no_duplicate_case_values
+    - no_logic_in_create_state
+    # - no_runtimeType_toString # ok in tests; we enable this only in packages/
     - non_constant_identifier_names
-    # - null_closures  # not yet tested
+    - null_check_on_nullable_type_parameter
+    - null_closures
     # - omit_local_variable_types # opposite of always_specify_types
     # - one_member_abstracts # too many false positives
     # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
@@ -108,43 +124,46 @@
     # - parameter_assignments # we do this commonly
     - prefer_adjacent_string_concatenation
     - prefer_asserts_in_initializer_lists
-    # - prefer_asserts_with_message # not yet tested
+    # - prefer_asserts_with_message # not required by flutter style
     - prefer_collection_literals
     - prefer_conditional_assignment
     - prefer_const_constructors
     - prefer_const_constructors_in_immutables
     - prefer_const_declarations
     - prefer_const_literals_to_create_immutables
-    # - prefer_constructors_over_static_methods # not yet tested
+    # - prefer_constructors_over_static_methods # far too many false positives
     - prefer_contains
     # - prefer_double_quotes # opposite of prefer_single_quotes
     - prefer_equal_for_default_values
     # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
     - prefer_final_fields
-    # - prefer_final_in_for_each # not yet tested
+    - prefer_final_in_for_each
     - prefer_final_locals
-    # - prefer_for_elements_to_map_fromIterable # not yet tested
+    - prefer_for_elements_to_map_fromIterable
     - prefer_foreach
-    # - prefer_function_declarations_over_variables # not yet tested
+    - prefer_function_declarations_over_variables
     - prefer_generic_function_type_aliases
-    # - prefer_if_elements_to_conditional_expressions # not yet tested
+    - prefer_if_elements_to_conditional_expressions
     - prefer_if_null_operators
     - prefer_initializing_formals
     - prefer_inlined_adds
-    # - prefer_int_literals # not yet tested
-    # - prefer_interpolation_to_compose_strings # not yet tested
+    # - prefer_int_literals # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#use-double-literals-for-double-constants
+    # - prefer_interpolation_to_compose_strings # doesn't work with raw strings, see https://github.com/dart-lang/linter/issues/2490
     - prefer_is_empty
     - prefer_is_not_empty
+    - prefer_is_not_operator
     - prefer_iterable_whereType
     # - prefer_mixin # https://github.com/dart-lang/language/issues/32
-    # - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932
+    - prefer_null_aware_operators
+    # - prefer_relative_imports # incompatible with sub-package imports
     - prefer_single_quotes
     - prefer_spread_collections
     - prefer_typing_uninitialized_variables
     - prefer_void_to_null
-    # - provide_deprecation_message # not yet tested
+    - provide_deprecation_message
     - public_member_api_docs
     - recursive_getters
+    - sized_box_for_whitespace
     - slash_for_doc_comments
     # - sort_child_properties_last # not yet tested
     - sort_constructors_first
@@ -152,28 +171,41 @@
     - sort_unnamed_constructors_first
     - test_types_in_equals
     - throw_in_finally
+    - tighten_type_of_initializing_formals
     # - type_annotate_public_apis # subset of always_specify_types
     - type_init_formals
     # - unawaited_futures # too many false positives
-    # - unnecessary_await_in_return # not yet tested
+    - unnecessary_await_in_return
     - unnecessary_brace_in_string_interps
     - unnecessary_const
+    # - unnecessary_final # conflicts with prefer_final_locals
     - unnecessary_getters_setters
     # - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
     - unnecessary_new
     - unnecessary_null_aware_assignments
+    # - unnecessary_null_checks # not yet tested
     - unnecessary_null_in_if_null_operators
+    - unnecessary_nullable_for_final_variable_declarations
     - unnecessary_overrides
     - unnecessary_parenthesis
+    # - unnecessary_raw_strings # not yet tested
     - unnecessary_statements
+    - unnecessary_string_escapes
+    - unnecessary_string_interpolations
     - unnecessary_this
     - unrelated_type_equality_checks
     # - unsafe_html # not yet tested
     - use_full_hex_values_for_flutter_colors
-    # - use_function_type_syntax_for_parameters # not yet tested
+    - use_function_type_syntax_for_parameters
+    # - use_if_null_to_convert_nulls_to_bools # not yet tested
+    - use_is_even_rather_than_modulo
+    - use_key_in_widget_constructors
+    - use_late_for_private_fields_and_variables
+    # - use_named_constants # not yet yested
+    - use_raw_strings
     - use_rethrow_when_possible
     # - use_setters_to_change_properties # not yet tested
     # - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
     # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
     - valid_regexps
-    # - void_checks # not yet tested
+    - void_checks
diff --git a/packages/animations/example/lib/container_transition.dart b/packages/animations/example/lib/container_transition.dart
index 0ba05a4..e26983f 100644
--- a/packages/animations/example/lib/container_transition.dart
+++ b/packages/animations/example/lib/container_transition.dart
@@ -40,6 +40,9 @@
 
 /// The demo page for [OpenContainerTransform].
 class OpenContainerTransformDemo extends StatefulWidget {
+  /// Creates the demo page for [OpenContainerTransform].
+  const OpenContainerTransformDemo({Key? key}) : super(key: key);
+
   @override
   _OpenContainerTransformDemoState createState() {
     return _OpenContainerTransformDemoState();
diff --git a/packages/animations/example/lib/fade_scale_transition.dart b/packages/animations/example/lib/fade_scale_transition.dart
index fb59084..08ec008 100644
--- a/packages/animations/example/lib/fade_scale_transition.dart
+++ b/packages/animations/example/lib/fade_scale_transition.dart
@@ -7,6 +7,9 @@
 
 /// The demo page for [FadeScaleTransition].
 class FadeScaleTransitionDemo extends StatefulWidget {
+  /// Creates the demo page for [FadeScaleTransition].
+  const FadeScaleTransitionDemo({Key? key}) : super(key: key);
+
   @override
   _FadeScaleTransitionDemoState createState() =>
       _FadeScaleTransitionDemoState();
diff --git a/packages/animations/example/lib/fade_through_transition.dart b/packages/animations/example/lib/fade_through_transition.dart
index 55fbeb7..65ccf49 100644
--- a/packages/animations/example/lib/fade_through_transition.dart
+++ b/packages/animations/example/lib/fade_through_transition.dart
@@ -7,6 +7,9 @@
 
 /// The demo page for [FadeThroughTransition].
 class FadeThroughTransitionDemo extends StatefulWidget {
+  /// Creates the demo page for [FadeThroughTransition].
+  const FadeThroughTransitionDemo({Key? key}) : super(key: key);
+
   @override
   _FadeThroughTransitionDemoState createState() =>
       _FadeThroughTransitionDemoState();
diff --git a/packages/animations/example/lib/main.dart b/packages/animations/example/lib/main.dart
index 39201f6..de137e3 100644
--- a/packages/animations/example/lib/main.dart
+++ b/packages/animations/example/lib/main.dart
@@ -51,7 +51,7 @@
                     Navigator.of(context).push(
                       MaterialPageRoute<void>(
                         builder: (BuildContext context) {
-                          return OpenContainerTransformDemo();
+                          return const OpenContainerTransformDemo();
                         },
                       ),
                     );
@@ -64,7 +64,7 @@
                     Navigator.of(context).push(
                       MaterialPageRoute<void>(
                         builder: (BuildContext context) {
-                          return SharedAxisTransitionDemo();
+                          return const SharedAxisTransitionDemo();
                         },
                       ),
                     );
@@ -77,7 +77,7 @@
                     Navigator.of(context).push(
                       MaterialPageRoute<void>(
                         builder: (BuildContext context) {
-                          return FadeThroughTransitionDemo();
+                          return const FadeThroughTransitionDemo();
                         },
                       ),
                     );
@@ -90,7 +90,7 @@
                     Navigator.of(context).push(
                       MaterialPageRoute<void>(
                         builder: (BuildContext context) {
-                          return FadeScaleTransitionDemo();
+                          return const FadeScaleTransitionDemo();
                         },
                       ),
                     );
diff --git a/packages/animations/example/lib/shared_axis_transition.dart b/packages/animations/example/lib/shared_axis_transition.dart
index 3c750a9..707e2fd 100644
--- a/packages/animations/example/lib/shared_axis_transition.dart
+++ b/packages/animations/example/lib/shared_axis_transition.dart
@@ -7,6 +7,9 @@
 
 /// The demo page for [SharedAxisPageTransitionsBuilder].
 class SharedAxisTransitionDemo extends StatefulWidget {
+  /// Creates the demo page for [SharedAxisPageTransitionsBuilder].
+  const SharedAxisTransitionDemo({Key? key}) : super(key: key);
+
   @override
   _SharedAxisTransitionDemoState createState() {
     return _SharedAxisTransitionDemoState();
diff --git a/packages/animations/lib/src/fade_through_transition.dart b/packages/animations/lib/src/fade_through_transition.dart
index dc962e0..8e70fc6 100644
--- a/packages/animations/lib/src/fade_through_transition.dart
+++ b/packages/animations/lib/src/fade_through_transition.dart
@@ -163,11 +163,12 @@
   /// The [animation] and [secondaryAnimation] argument are required and must
   /// not be null.
   const FadeThroughTransition({
+    Key? key,
     required this.animation,
     required this.secondaryAnimation,
     this.fillColor,
     this.child,
-  });
+  }) : super(key: key);
 
   /// The animation that drives the [child]'s entrance and exit.
   ///
diff --git a/packages/animations/lib/src/open_container.dart b/packages/animations/lib/src/open_container.dart
index 0a1252c..a394519 100644
--- a/packages/animations/lib/src/open_container.dart
+++ b/packages/animations/lib/src/open_container.dart
@@ -649,7 +649,7 @@
     final RenderBox navigator = Navigator.of(
       navigatorContext,
       rootNavigator: useRootNavigator,
-    ).context.findRenderObject() as RenderBox;
+    ).context.findRenderObject()! as RenderBox;
     final Size navSize = _getSize(navigator);
     _rectTween.end = Offset.zero & navSize;
 
@@ -680,7 +680,7 @@
     assert(key.currentContext != null);
     assert(ancestor.hasSize);
     final RenderBox render =
-        key.currentContext!.findRenderObject() as RenderBox;
+        key.currentContext!.findRenderObject()! as RenderBox;
     assert(render.hasSize);
     return MatrixUtils.transformRect(
       render.getTransformTo(ancestor),
diff --git a/packages/animations/lib/src/page_transition_switcher.dart b/packages/animations/lib/src/page_transition_switcher.dart
index 364e557..ad00703 100644
--- a/packages/animations/lib/src/page_transition_switcher.dart
+++ b/packages/animations/lib/src/page_transition_switcher.dart
@@ -423,7 +423,7 @@
 
   @override
   void dispose() {
-    for (_ChildEntry entry in _activeEntries) {
+    for (final _ChildEntry entry in _activeEntries) {
       entry.dispose();
     }
     super.dispose();
diff --git a/packages/animations/test/fade_through_transition_test.dart b/packages/animations/test/fade_through_transition_test.dart
index 26f8934..ac0ba19 100644
--- a/packages/animations/test/fade_through_transition_test.dart
+++ b/packages/animations/test/fade_through_transition_test.dart
@@ -477,11 +477,9 @@
           builder: (BuildContext context) {
             return contentBuilder != null
                 ? contentBuilder!(settings)
-                : Container(
-                    child: Center(
-                      key: ValueKey<String?>(settings.name),
-                      child: Text(settings.name!),
-                    ),
+                : Center(
+                    key: ValueKey<String?>(settings.name),
+                    child: Text(settings.name!),
                   );
           },
         );
diff --git a/packages/animations/test/open_container_test.dart b/packages/animations/test/open_container_test.dart
index 10ae379..1b05f44 100644
--- a/packages/animations/test/open_container_test.dart
+++ b/packages/animations/test/open_container_test.dart
@@ -854,10 +854,10 @@
       (WidgetTester tester) async {
     final Widget openContainer = OpenContainer(
       closedBuilder: (BuildContext context, VoidCallback action) {
-        return Container(
+        return const SizedBox(
           height: 100,
           width: 100,
-          child: const Text('Closed'),
+          child: Text('Closed'),
         );
       },
       openBuilder: (BuildContext context, VoidCallback action) {
@@ -1889,15 +1889,18 @@
   final Widget child;
 
   @override
-  State<_SizableContainer> createState() =>
-      _SizableContainerState(size: initialSize);
+  State<_SizableContainer> createState() => _SizableContainerState();
 }
 
 class _SizableContainerState extends State<_SizableContainer> {
-  _SizableContainerState({required double size}) : _size = size;
+  @override
+  void initState() {
+    super.initState();
+    _size = widget.initialSize;
+  }
 
   double get size => _size;
-  double _size;
+  late double _size;
   set size(double value) {
     if (value == _size) {
       return;
@@ -1909,7 +1912,7 @@
 
   @override
   Widget build(BuildContext context) {
-    return Container(
+    return SizedBox(
       height: size,
       width: size,
       child: widget.child,
diff --git a/packages/animations/test/page_transition_switcher_test.dart b/packages/animations/test/page_transition_switcher_test.dart
index 62c610c..ad3965e 100644
--- a/packages/animations/test/page_transition_switcher_test.dart
+++ b/packages/animations/test/page_transition_switcher_test.dart
@@ -619,7 +619,7 @@
 Map<Key, double> _getSecondaryAnimation(List<Key> keys, WidgetTester tester) {
   expect(find.byType(FadeTransition), findsNWidgets(keys.length));
   final Map<Key, double> result = <Key, double>{};
-  for (Key key in keys) {
+  for (final Key key in keys) {
     final FadeTransition transition = tester.firstWidget(
       find.ancestor(
         of: find.byKey(key),
@@ -634,7 +634,7 @@
 Map<Key, double> _getPrimaryAnimation(List<Key> keys, WidgetTester tester) {
   expect(find.byType(ScaleTransition), findsNWidgets(keys.length));
   final Map<Key, double> result = <Key, double>{};
-  for (Key key in keys) {
+  for (final Key key in keys) {
     final ScaleTransition transition = tester.firstWidget(
       find.ancestor(
         of: find.byKey(key),
diff --git a/packages/animations/test/shared_axis_transition_test.dart b/packages/animations/test/shared_axis_transition_test.dart
index 1c7ea60..03ac704 100644
--- a/packages/animations/test/shared_axis_transition_test.dart
+++ b/packages/animations/test/shared_axis_transition_test.dart
@@ -1921,11 +1921,9 @@
           builder: (BuildContext context) {
             return contentBuilder != null
                 ? contentBuilder!(settings)
-                : Container(
-                    child: Center(
-                      key: ValueKey<String?>(settings.name),
-                      child: Text(settings.name!),
-                    ),
+                : Center(
+                    key: ValueKey<String?>(settings.name),
+                    child: Text(settings.name!),
                   );
           },
         );
diff --git a/packages/cross_file/test/x_file_html_test.dart b/packages/cross_file/test/x_file_html_test.dart
index 43740f0..aadcc20 100644
--- a/packages/cross_file/test/x_file_html_test.dart
+++ b/packages/cross_file/test/x_file_html_test.dart
@@ -75,9 +75,9 @@
 
         await file.saveTo('path');
 
-        final html.Element? container =
-            html.querySelector('#$crossFileDomElementId');
-        final html.AnchorElement element = container?.children
+        final html.Element container =
+            html.querySelector('#$crossFileDomElementId')!;
+        final html.AnchorElement element = container.children
                 .firstWhere((html.Element element) => element.tagName == 'A')
             as html.AnchorElement;
 
diff --git a/packages/extension_google_sign_in_as_googleapis_auth/example/lib/main.dart b/packages/extension_google_sign_in_as_googleapis_auth/example/lib/main.dart
index 6fe6120..3074be4 100755
--- a/packages/extension_google_sign_in_as_googleapis_auth/example/lib/main.dart
+++ b/packages/extension_google_sign_in_as_googleapis_auth/example/lib/main.dart
@@ -19,7 +19,7 @@
 
 void main() {
   runApp(
-    MaterialApp(
+    const MaterialApp(
       title: 'Google Sign In',
       home: SignInDemo(),
     ),
@@ -28,6 +28,9 @@
 
 /// The main widget of this demo.
 class SignInDemo extends StatefulWidget {
+  /// Creates the main widget of this demo.
+  const SignInDemo({Key? key}) : super(key: key);
+
   @override
   State createState() => SignInDemoState();
 }
diff --git a/packages/fuchsia_ctl/bin/main.dart b/packages/fuchsia_ctl/bin/main.dart
index cfd76ea..014fa30 100644
--- a/packages/fuchsia_ctl/bin/main.dart
+++ b/packages/fuchsia_ctl/bin/main.dart
@@ -180,7 +180,7 @@
   final String identityFile = args['identity-file'];
   final String outputFile = args['log-file'];
   if (args['interactive']) {
-    return await sshClient.interactive(
+    return sshClient.interactive(
       targetIp,
       identityFilePath: identityFile,
     );
@@ -213,7 +213,7 @@
     maxDelay: Duration(seconds: 30),
     maxAttempts: 3,
   );
-  return await r.retry(() async {
+  return r.retry(() async {
     final OperationResult result = await paver.pave(
       args['image'],
       deviceName,
@@ -237,11 +237,11 @@
     case 'serve':
       await server.serveRepo(args['repo']);
       await Future<void>.delayed(const Duration(seconds: 15));
-      return await server.close();
+      return server.close();
     case 'newRepo':
-      return await server.newRepo(args['repo']);
+      return server.newRepo(args['repo']);
     case 'publishRepo':
-      return await server.publishRepo(args['repo'], args['far']);
+      return server.publishRepo(args['repo'], args['far']);
     default:
       throw ArgumentError('Command ${args.command.name} unknown.');
   }
@@ -281,7 +281,7 @@
     await amberCtl.addSrc(server.serverPort);
 
     stdout.writeln('Pushing packages $packages to $targetIp');
-    for (String packageName in packages) {
+    for (final String packageName in packages) {
       stdout.writeln('Attempting to add package $packageName.');
       await amberCtl.addPackage(packageName);
     }
@@ -348,7 +348,7 @@
     await server.serveRepo(repo.path, port: 0);
     await amberCtl.addSrc(server.serverPort);
 
-    for (String farFile in farFiles) {
+    for (final String farFile in farFiles) {
       result = await server.publishRepo(repo.path, farFile);
       if (!result.success) {
         stderr.writeln('Failed to publish repo at $repo with $farFiles.');
diff --git a/packages/fuchsia_ctl/lib/src/amber_ctl.dart b/packages/fuchsia_ctl/lib/src/amber_ctl.dart
index 5d2f682..8d0e6a4 100644
--- a/packages/fuchsia_ctl/lib/src/amber_ctl.dart
+++ b/packages/fuchsia_ctl/lib/src/amber_ctl.dart
@@ -79,7 +79,7 @@
   Future<String> _getLocalIp(String targetIp) async {
     final OperationResult result = await _kSsh.runCommand(targetIp,
         identityFilePath: _identityFile,
-        command: <String>['echo \$SSH_CONNECTION']);
+        command: <String>[r'echo $SSH_CONNECTION']);
 
     if (!result.success) {
       throw AmberCtlException('Failed to get local address, aborting.', result);
diff --git a/packages/fuchsia_ctl/test/image_paver_test.dart b/packages/fuchsia_ctl/test/image_paver_test.dart
index ee0df4f..41888b8 100644
--- a/packages/fuchsia_ctl/test/image_paver_test.dart
+++ b/packages/fuchsia_ctl/test/image_paver_test.dart
@@ -163,7 +163,7 @@
     if (passes) {
       final Directory dir = fs.directory(destination)
         ..createSync(recursive: true);
-      dir.childFile('pave.sh')..createSync();
+      dir.childFile('pave.sh').createSync();
       return OperationResult.success();
     }
     return OperationResult.error('tar failed');
diff --git a/packages/imitation_game/bin/imitation_game.dart b/packages/imitation_game/bin/imitation_game.dart
index 411911a..4bfa7e7 100644
--- a/packages/imitation_game/bin/imitation_game.dart
+++ b/packages/imitation_game/bin/imitation_game.dart
@@ -2,7 +2,7 @@
 import 'dart:convert';
 import 'dart:io';
 import 'package:mustache/mustache.dart';
-import 'package:imitation_game/README_template.dart';
+import 'package:imitation_game/readme_template.dart';
 import 'package:args/args.dart';
 
 // ignore_for_file: avoid_as
@@ -12,8 +12,8 @@
 Future<String> _findIpAddress() async {
   String result;
   final List<NetworkInterface> interfaces = await NetworkInterface.list();
-  for (NetworkInterface interface in interfaces) {
-    for (InternetAddress address in interface.addresses) {
+  for (final NetworkInterface interface in interfaces) {
+    for (final InternetAddress address in interface.addresses) {
       if (address.type == InternetAddressType.IPv4) {
         // TODO(gaaclarke): Implment having multiple addresses.
         assert(result == null);
@@ -202,7 +202,7 @@
   final String ipaddress = await _findIpAddress();
   print('Listening on $ipaddress:${server.port}');
 
-  for (FileSystemEntity entity in await findFiles(Directory.current,
+  for (final FileSystemEntity entity in await findFiles(Directory.current,
       where: (FileSystemEntity f) => f.path.endsWith('ip.txt'))) {
     final File file = File(entity.path);
     file.writeAsStringSync('$ipaddress:${server.port}');
@@ -233,7 +233,7 @@
         print('TIMEOUT!');
         throw TimeoutException('timeout');
       });
-      await for (HttpRequest request in timeoutServer) {
+      await for (final HttpRequest request in timeoutServer) {
         print('got request: ${request.method}');
         if (request.method == 'POST') {
           final String content = await utf8.decoder.bind(request).join();
diff --git a/packages/imitation_game/imitation_tests/smiley/flutter/smiley/lib/main.dart b/packages/imitation_game/imitation_tests/smiley/flutter/smiley/lib/main.dart
index a7c2d7d..adec8c1 100644
--- a/packages/imitation_game/imitation_tests/smiley/flutter/smiley/lib/main.dart
+++ b/packages/imitation_game/imitation_tests/smiley/flutter/smiley/lib/main.dart
@@ -13,7 +13,7 @@
 String _hostIp;
 
 Future<String> _getHostIp() async {
-  return await rootBundle.loadString('assets/ip.txt');
+  return rootBundle.loadString('assets/ip.txt');
 }
 
 Future<void> _sendResult(double result) async {
@@ -38,7 +38,7 @@
 }
 
 void main() {
-  runApp(MyApp());
+  runApp(const MyApp());
   // Hide status bar.
   SystemChrome.setEnabledSystemUIOverlays(<SystemUiOverlay>[]);
   _getHostIp().then((String ip) async {
@@ -48,6 +48,9 @@
 
 /// Top level Material App.
 class MyApp extends StatelessWidget {
+  /// Create top level Material App.
+  const MyApp({Key key}) : super(key: key);
+
   @override
   Widget build(BuildContext context) {
     return MaterialApp(
@@ -104,7 +107,7 @@
         child: Column(
           mainAxisAlignment: MainAxisAlignment.center,
           children: <Widget>[
-            _loading ? Container() : Image(image: _image),
+            if (_loading) Container() else Image(image: _image),
           ],
         ),
       ),
diff --git a/packages/imitation_game/lib/README_template.dart b/packages/imitation_game/lib/readme_template.dart
similarity index 98%
rename from packages/imitation_game/lib/README_template.dart
rename to packages/imitation_game/lib/readme_template.dart
index cbff0d3..fc69cfb 100644
--- a/packages/imitation_game/lib/README_template.dart
+++ b/packages/imitation_game/lib/readme_template.dart
@@ -1,5 +1,6 @@
 /// Mustache template used for generating README.md.
-String readmeTemplate = """# Imitation Game
+String readmeTemplate = """
+# Imitation Game
 
 ## Description
 
diff --git a/packages/imitation_game/pubspec.yaml b/packages/imitation_game/pubspec.yaml
index eb480f1..fea3802 100644
--- a/packages/imitation_game/pubspec.yaml
+++ b/packages/imitation_game/pubspec.yaml
@@ -6,4 +6,4 @@
   args: ^1.6.0
   mustache: ^1.1.1
 environment:
-  sdk: ">=1.8.0 <3.0.0"
+  sdk: ">=2.7.0 <3.0.0"
diff --git a/packages/metrics_center/lib/src/gcs_lock.dart b/packages/metrics_center/lib/src/gcs_lock.dart
index 1150e22..47d0d23 100644
--- a/packages/metrics_center/lib/src/gcs_lock.dart
+++ b/packages/metrics_center/lib/src/gcs_lock.dart
@@ -30,7 +30,8 @@
   /// If the lock file is stuck (e.g., `_unlock` is interrupted unexpectedly),
   /// one may need to manually delete the lock file from GCS to unblock any
   /// [protectedRun] that may depend on it.
-  Future<void> protectedRun(String lockFileName, Future<void> f()) async {
+  Future<void> protectedRun(
+      String lockFileName, Future<void> Function() f) async {
     await _lock(lockFileName);
     try {
       await f();
diff --git a/packages/metrics_center/lib/src/skiaperf.dart b/packages/metrics_center/lib/src/skiaperf.dart
index b663de1..b145857 100644
--- a/packages/metrics_center/lib/src/skiaperf.dart
+++ b/packages/metrics_center/lib/src/skiaperf.dart
@@ -257,7 +257,7 @@
       }
     }
     // Retry one last time and let the exception go through.
-    return await _readPointsWithoutRetry(objectName);
+    return _readPointsWithoutRetry(objectName);
   }
 
   Future<List<SkiaPerfPoint>> _readPointsWithoutRetry(String objectName) async {
diff --git a/packages/multicast_dns/example/main.dart b/packages/multicast_dns/example/main.dart
index e6cc74f..d15f665 100644
--- a/packages/multicast_dns/example/main.dart
+++ b/packages/multicast_dns/example/main.dart
@@ -16,13 +16,13 @@
   await client.start();
 
   // Get the PTR record for the service.
-  await for (PtrResourceRecord ptr in client
+  await for (final PtrResourceRecord ptr in client
       .lookup<PtrResourceRecord>(ResourceRecordQuery.serverPointer(name))) {
     // Use the domainName from the PTR record to get the SRV record,
     // which will have the port and local hostname.
     // Note that duplicate messages may come through, especially if any
     // other mDNS queries are running elsewhere on the machine.
-    await for (SrvResourceRecord srv in client.lookup<SrvResourceRecord>(
+    await for (final SrvResourceRecord srv in client.lookup<SrvResourceRecord>(
         ResourceRecordQuery.service(ptr.domainName))) {
       // Domain name will be something like "io.flutter.example@some-iphone.local._dartobservatory._tcp.local"
       final String bundleId =
diff --git a/packages/multicast_dns/example/mdns-resolve.dart b/packages/multicast_dns/example/mdns_resolve.dart
similarity index 84%
rename from packages/multicast_dns/example/mdns-resolve.dart
rename to packages/multicast_dns/example/mdns_resolve.dart
index 2276b3b..13441d6 100644
--- a/packages/multicast_dns/example/mdns-resolve.dart
+++ b/packages/multicast_dns/example/mdns_resolve.dart
@@ -13,7 +13,7 @@
 Please provide an address as argument.
 
 For example:
-  dart mdns-resolve.dart dartino.local''');
+  dart mdns_resolve.dart dartino.local''');
     return;
   }
 
@@ -21,12 +21,12 @@
 
   final MDnsClient client = MDnsClient();
   await client.start();
-  await for (IPAddressResourceRecord record in client
+  await for (final IPAddressResourceRecord record in client
       .lookup<IPAddressResourceRecord>(ResourceRecordQuery.addressIPv4(name))) {
     print('Found address (${record.address}).');
   }
 
-  await for (IPAddressResourceRecord record in client
+  await for (final IPAddressResourceRecord record in client
       .lookup<IPAddressResourceRecord>(ResourceRecordQuery.addressIPv6(name))) {
     print('Found address (${record.address}).');
   }
diff --git a/packages/multicast_dns/example/mdns-sd.dart b/packages/multicast_dns/example/mdns_sd.dart
similarity index 85%
rename from packages/multicast_dns/example/mdns-sd.dart
rename to packages/multicast_dns/example/mdns_sd.dart
index f431ee6..b4d05ad 100644
--- a/packages/multicast_dns/example/mdns-sd.dart
+++ b/packages/multicast_dns/example/mdns_sd.dart
@@ -13,7 +13,7 @@
 Please provide the name of a service as argument.
 
 For example:
-  dart mdns-sd.dart [--verbose] _workstation._tcp.local''');
+  dart mdns_sd.dart [--verbose] _workstation._tcp.local''');
     return;
   }
 
@@ -22,12 +22,12 @@
   final MDnsClient client = MDnsClient();
   await client.start();
 
-  await for (PtrResourceRecord ptr in client
+  await for (final PtrResourceRecord ptr in client
       .lookup<PtrResourceRecord>(ResourceRecordQuery.serverPointer(name))) {
     if (verbose) {
       print(ptr);
     }
-    await for (SrvResourceRecord srv in client.lookup<SrvResourceRecord>(
+    await for (final SrvResourceRecord srv in client.lookup<SrvResourceRecord>(
         ResourceRecordQuery.service(ptr.domainName))) {
       if (verbose) {
         print(srv);
@@ -37,7 +37,7 @@
             .lookup<TxtResourceRecord>(ResourceRecordQuery.text(ptr.domainName))
             .forEach(print);
       }
-      await for (IPAddressResourceRecord ip
+      await for (final IPAddressResourceRecord ip
           in client.lookup<IPAddressResourceRecord>(
               ResourceRecordQuery.addressIPv4(srv.target))) {
         if (verbose) {
@@ -46,7 +46,7 @@
         print('Service instance found at '
             '${srv.target}:${srv.port} with ${ip.address}.');
       }
-      await for (IPAddressResourceRecord ip
+      await for (final IPAddressResourceRecord ip
           in client.lookup<IPAddressResourceRecord>(
               ResourceRecordQuery.addressIPv6(srv.target))) {
         if (verbose) {
diff --git a/packages/multicast_dns/lib/multicast_dns.dart b/packages/multicast_dns/lib/multicast_dns.dart
index 148a4b0..0b014cf 100644
--- a/packages/multicast_dns/lib/multicast_dns.dart
+++ b/packages/multicast_dns/lib/multicast_dns.dart
@@ -57,12 +57,14 @@
   int? _mDnsPort;
 
   /// Find all network interfaces with an the [InternetAddressType] specified.
-  static NetworkInterfacesFactory allInterfacesFactory =
-      (InternetAddressType type) => NetworkInterface.list(
-            includeLinkLocal: true,
-            type: type,
-            includeLoopback: true,
-          );
+  Future<Iterable<NetworkInterface>> allInterfacesFactory(
+      InternetAddressType type) {
+    return NetworkInterface.list(
+      includeLinkLocal: true,
+      type: type,
+      includeLoopback: true,
+    );
+  }
 
   /// Start the mDNS client.
   ///
@@ -120,7 +122,7 @@
     final List<NetworkInterface> interfaces =
         (await interfacesFactory(listenAddress.type)).toList();
 
-    for (NetworkInterface interface in interfaces) {
+    for (final NetworkInterface interface in interfaces) {
       // Create a socket for sending on each adapter.
       final InternetAddress targetAddress = interface.addresses[0];
       final RawDatagramSocket socket = await _rawDatagramSocketFactory(
@@ -162,7 +164,7 @@
       throw StateError('Cannot stop mDNS client while it is starting.');
     }
 
-    for (RawDatagramSocket socket in _sockets) {
+    for (final RawDatagramSocket socket in _sockets) {
       socket.close();
     }
 
@@ -206,7 +208,7 @@
 
     // Send the request on all interfaces.
     final List<int> packet = query.encode();
-    for (RawDatagramSocket socket in _sockets) {
+    for (final RawDatagramSocket socket in _sockets) {
       socket.send(packet, _mDnsAddress!, selectedMDnsPort);
     }
     return results;
diff --git a/packages/multicast_dns/lib/src/lookup_resolver.dart b/packages/multicast_dns/lib/src/lookup_resolver.dart
index 40cc86b..a25e691 100644
--- a/packages/multicast_dns/lib/src/lookup_resolver.dart
+++ b/packages/multicast_dns/lib/src/lookup_resolver.dart
@@ -51,7 +51,7 @@
   /// Parses [ResoureRecord]s received and delivers them to the appropriate
   /// listener(s) added via [addPendingRequest].
   void handleResponse(List<ResourceRecord> response) {
-    for (ResourceRecord r in response) {
+    for (final ResourceRecord r in response) {
       final int type = r.resourceRecordType;
       String name = r.name.toLowerCase();
       if (name.endsWith('.')) {
@@ -73,7 +73,7 @@
         return requestName == name && request.type == type;
       }
 
-      for (PendingRequest pendingRequest in _pendingRequests) {
+      for (final PendingRequest pendingRequest in _pendingRequests) {
         if (responseMatches(pendingRequest)) {
           if (pendingRequest.controller.isClosed) {
             return;
diff --git a/packages/multicast_dns/lib/src/native_protocol_client.dart b/packages/multicast_dns/lib/src/native_protocol_client.dart
index 734412b..15e70c9 100644
--- a/packages/multicast_dns/lib/src/native_protocol_client.dart
+++ b/packages/multicast_dns/lib/src/native_protocol_client.dart
@@ -41,7 +41,7 @@
     // necessary.
     // Clear the cache for all name/type combinations to be updated.
     final Map<int, Set<String>> seenRecordTypes = <int, Set<String>>{};
-    for (ResourceRecord record in records) {
+    for (final ResourceRecord record in records) {
       // TODO(dnfield): Update this to use set literal syntax when we're able to bump the SDK constraint.
       seenRecordTypes[record.resourceRecordType] ??=
           Set<String>(); // ignore: prefer_collection_literals
diff --git a/packages/multicast_dns/lib/src/resource_record.dart b/packages/multicast_dns/lib/src/resource_record.dart
index eae21bf..5a752b7 100644
--- a/packages/multicast_dns/lib/src/resource_record.dart
+++ b/packages/multicast_dns/lib/src/resource_record.dart
@@ -6,6 +6,7 @@
 import 'dart:io';
 import 'dart:typed_data';
 
+import 'package:meta/meta.dart';
 import 'package:multicast_dns/src/constants.dart';
 import 'package:multicast_dns/src/packet.dart';
 
@@ -84,6 +85,7 @@
 }
 
 /// Represents a DNS query.
+@immutable
 class ResourceRecordQuery {
   /// Creates a new ResourceRecordQuery.
   ///
@@ -186,6 +188,7 @@
 }
 
 /// Base implementation of DNS resource records (RRs).
+@immutable
 abstract class ResourceRecord {
   /// Creates a new ResourceRecord.
   const ResourceRecord(this.resourceRecordType, this.name, this.validUntil);
@@ -241,7 +244,7 @@
 /// A Service Pointer for reverse mapping an IP address (DNS "PTR").
 class PtrResourceRecord extends ResourceRecord {
   /// Creates a new PtrResourceRecord.
-  PtrResourceRecord(
+  const PtrResourceRecord(
     String name,
     int validUntil, {
     required this.domainName,
@@ -306,7 +309,7 @@
 /// A Service record, capturing a host target and port (DNS "SRV").
 class SrvResourceRecord extends ResourceRecord {
   /// Creates a new service record.
-  SrvResourceRecord(
+  const SrvResourceRecord(
     String name,
     int validUntil, {
     required this.target,
@@ -364,7 +367,7 @@
 /// A Text record, contianing additional textual data (DNS "TXT").
 class TxtResourceRecord extends ResourceRecord {
   /// Creates a new text record.
-  TxtResourceRecord(
+  const TxtResourceRecord(
     String name,
     int validUntil, {
     required this.text,
diff --git a/packages/multicast_dns/pubspec.yaml b/packages/multicast_dns/pubspec.yaml
index d59445f..058d0c4 100644
--- a/packages/multicast_dns/pubspec.yaml
+++ b/packages/multicast_dns/pubspec.yaml
@@ -3,6 +3,9 @@
 homepage: https://github.com/flutter/packages/tree/master/packages/multicast_dns
 version: 0.3.0
 
+dependencies:
+  meta: ^1.3.0
+
 dev_dependencies:
   test: "^1.16.5"
 
diff --git a/packages/multicast_dns/test/decode_test.dart b/packages/multicast_dns/test/decode_test.dart
index e8c1afa..f6c5e88 100644
--- a/packages/multicast_dns/test/decode_test.dart
+++ b/packages/multicast_dns/test/decode_test.dart
@@ -186,7 +186,7 @@
 
 void testBadPackages() {
   test('Returns null for invalid packets', () {
-    for (List<int> p in <List<int>>[package1, package2, package3]) {
+    for (final List<int> p in <List<int>>[package1, package2, package3]) {
       for (int i = 0; i < p.length; i++) {
         expect(decodeMDnsResponse(p.sublist(0, i)), isNull);
       }
diff --git a/packages/palette_generator/example/lib/main.dart b/packages/palette_generator/example/lib/main.dart
index e445e5b..9e01739 100644
--- a/packages/palette_generator/example/lib/main.dart
+++ b/packages/palette_generator/example/lib/main.dart
@@ -10,7 +10,7 @@
 
 import 'package:palette_generator/palette_generator.dart';
 
-void main() => runApp(MyApp());
+void main() => runApp(const MyApp());
 
 const Color _kBackgroundColor = Color(0xffa0a0a0);
 const Color _kSelectionRectangleBackground = Color(0x15000000);
@@ -19,6 +19,9 @@
 
 /// The main Application class.
 class MyApp extends StatelessWidget {
+  /// Creates the main Application class.
+  const MyApp({Key? key}) : super(key: key);
+
   // This widget is the root of your application.
   @override
   Widget build(BuildContext context) {
@@ -93,7 +96,7 @@
   // Called when the user starts to drag
   void _onPanDown(DragDownDetails details) {
     final RenderBox box =
-        imageKey.currentContext!.findRenderObject() as RenderBox;
+        imageKey.currentContext!.findRenderObject()! as RenderBox;
     final Offset localPosition = box.globalToLocal(details.globalPosition);
     setState(() {
       startDrag = localPosition;
@@ -210,7 +213,7 @@
     if (paletteGen == null || paletteGen.colors.isEmpty) {
       return Container();
     }
-    for (Color color in paletteGen.colors) {
+    for (final Color color in paletteGen.colors) {
       swatches.add(PaletteSwatch(color: color));
     }
     return Column(
diff --git a/packages/palette_generator/lib/palette_generator.dart b/packages/palette_generator/lib/palette_generator.dart
index 2869155..ed721f5 100644
--- a/packages/palette_generator/lib/palette_generator.dart
+++ b/packages/palette_generator/lib/palette_generator.dart
@@ -2,6 +2,9 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+// TODO(goderbauer): Fix this warning for the classes in this file.
+// ignore_for_file: avoid_equals_and_hash_code_on_mutable_classes
+
 import 'dart:async';
 import 'dart:collection';
 import 'dart:math' as math;
@@ -233,7 +236,7 @@
   /// Returns a list of colors in the [paletteColors], sorted from most
   /// dominant to least dominant color.
   Iterable<Color> get colors sync* {
-    for (PaletteColor paletteColor in paletteColors) {
+    for (final PaletteColor paletteColor in paletteColors) {
       yield paletteColor.color;
     }
   }
@@ -285,7 +288,7 @@
     final Set<PaletteTarget> allTargets =
         Set<PaletteTarget>.from(targets + PaletteTarget.baseTargets);
     final Set<Color> usedColors = <Color>{};
-    for (PaletteTarget target in allTargets) {
+    for (final PaletteTarget target in allTargets) {
       target._normalizeWeights();
       final PaletteColor? targetScore =
           _generateScoredTarget(target, usedColors);
@@ -311,7 +314,7 @@
       PaletteTarget target, Set<Color> usedColors) {
     double maxScore = 0.0;
     PaletteColor? maxScoreSwatch;
-    for (PaletteColor paletteColor in paletteColors) {
+    for (final PaletteColor paletteColor in paletteColors) {
       if (_shouldBeScoredForTarget(paletteColor, target, usedColors)) {
         final double score = _generateScore(paletteColor, target);
         if (maxScoreSwatch == null || score > maxScore) {
@@ -1059,8 +1062,8 @@
     }
   }
 
-  void removeWhere(bool predicate(Color key)) {
-    for (Color key in _keys) {
+  void removeWhere(bool Function(Color key) predicate) {
+    for (final Color key in _keys) {
       if (predicate(key)) {
         _hist[key.red]?[key.blue]?.remove(key.green);
       }
@@ -1140,7 +1143,7 @@
   bool _shouldIgnoreColor(Color color) {
     final HSLColor hslColor = HSLColor.fromColor(color);
     if (filters.isNotEmpty) {
-      for (PaletteFilter filter in filters) {
+      for (final PaletteFilter filter in filters) {
         if (!filter(hslColor)) {
           return true;
         }
@@ -1176,7 +1179,7 @@
     Color? currentColor;
     _ColorCount? currentColorCount;
 
-    for (Color pixel in pixels) {
+    for (final Color pixel in pixels) {
       // Update the histogram, but only for non-zero alpha values, and for the
       // ones we do add, make their alphas opaque so that we can use a Color as
       // the histogram key.
@@ -1203,7 +1206,7 @@
       // The image has fewer colors than the maximum requested, so just return
       // the colors.
       _paletteColors.clear();
-      for (Color color in hist.keys) {
+      for (final Color color in hist.keys) {
         _paletteColors.add(PaletteColor(color, hist[color]!.value));
       }
     } else {
@@ -1260,7 +1263,7 @@
   List<PaletteColor> _generateAverageColors(
       PriorityQueue<_ColorVolumeBox> colorVolumeBoxes) {
     final List<PaletteColor> colors = <PaletteColor>[];
-    for (_ColorVolumeBox colorVolumeBox in colorVolumeBoxes.toList()) {
+    for (final _ColorVolumeBox colorVolumeBox in colorVolumeBoxes.toList()) {
       final PaletteColor paletteColor = colorVolumeBox.getAverageColor();
       if (!_shouldIgnoreColor(paletteColor.color)) {
         colors.add(paletteColor);
diff --git a/packages/palette_generator/test/palette_generator_test.dart b/packages/palette_generator/test/palette_generator_test.dart
index 336ec8c..375b5db 100644
--- a/packages/palette_generator/test/palette_generator_test.dart
+++ b/packages/palette_generator/test/palette_generator_test.dart
@@ -60,7 +60,7 @@
     'landscape'
   ];
   final Map<String, ImageProvider> testImages = <String, ImageProvider>{};
-  for (String name in imageNames) {
+  for (final String name in imageNames) {
     testImages[name] = await loadImage('$name.png');
   }
 
diff --git a/packages/pigeon/bin/pigeon.dart b/packages/pigeon/bin/pigeon.dart
index 1a424e0..33f44a1 100644
--- a/packages/pigeon/bin/pigeon.dart
+++ b/packages/pigeon/bin/pigeon.dart
@@ -37,7 +37,8 @@
     final String relInputPath = _posixRelative(opts.input, from: tempDir.path);
     importLine = 'import \'$relInputPath\';\n';
   }
-  final String code = """// @dart = 2.2
+  final String code = """
+// @dart = 2.2
 $importLine
 import 'dart:io';
 import 'dart:isolate';
diff --git a/packages/pigeon/e2e_tests/test_objc/lib/main.dart b/packages/pigeon/e2e_tests/test_objc/lib/main.dart
index d9589ed..4e74743 100644
--- a/packages/pigeon/e2e_tests/test_objc/lib/main.dart
+++ b/packages/pigeon/e2e_tests/test_objc/lib/main.dart
@@ -11,11 +11,14 @@
 void main() {
   WidgetsFlutterBinding.ensureInitialized();
   FlutterSearchApi.setup(_MyFlutterSearchApi());
-  runApp(MyApp());
+  runApp(const MyApp());
 }
 
 /// Main widget for the tests.
 class MyApp extends StatelessWidget {
+  /// Creates the main widget for the tests.
+  const MyApp({Key key}) : super(key: key);
+
   @override
   Widget build(BuildContext context) {
     return MaterialApp(
@@ -62,7 +65,7 @@
               'Message:',
             ),
             Text(
-              '$_message',
+              _message,
               style: Theme.of(context).textTheme.headline1,
             ),
           ],
diff --git a/packages/pigeon/e2e_tests/test_objc/test_driver/widget_test.dart b/packages/pigeon/e2e_tests/test_objc/test_driver/widget_test.dart
index da52b7b..300082d 100644
--- a/packages/pigeon/e2e_tests/test_objc/test_driver/widget_test.dart
+++ b/packages/pigeon/e2e_tests/test_objc/test_driver/widget_test.dart
@@ -13,7 +13,7 @@
 void main() {
   testWidgets('Counter increments smoke test', (WidgetTester tester) async {
     // Build our app and trigger a frame.
-    await tester.pumpWidget(MyApp());
+    await tester.pumpWidget(const MyApp());
 
     // Verify that our counter starts at 0.
     expect(find.text('0'), findsOneWidget);
diff --git a/packages/pigeon/lib/dart_generator.dart b/packages/pigeon/lib/dart_generator.dart
index ca94c97..a33b91f 100644
--- a/packages/pigeon/lib/dart_generator.dart
+++ b/packages/pigeon/lib/dart_generator.dart
@@ -25,7 +25,7 @@
   bool first = true;
   indent.write('class ${api.name} ');
   indent.scoped('{', '}', () {
-    for (Method func in api.methods) {
+    for (final Method func in api.methods) {
       if (!first) {
         indent.writeln('');
       } else {
@@ -56,8 +56,8 @@
         final String returnStatement = func.returnType == 'void'
             ? '// noop'
             : 'return ${func.returnType}.decode(replyMap[\'${Keys.result}\']$unwrapOperator);';
-        indent.format(
-            '''final Map<Object$nullTag, Object$nullTag>$nullTag replyMap = await channel.send($sendArgument) as Map<Object$nullTag, Object$nullTag>$nullTag;
+        indent.format('''
+final Map<Object$nullTag, Object$nullTag>$nullTag replyMap = await channel.send($sendArgument) as Map<Object$nullTag, Object$nullTag>$nullTag;
 if (replyMap == null) {
 \tthrow PlatformException(
 \t\tcode: 'channel-error',
@@ -91,17 +91,17 @@
   final String unwrapOperator = opt.isNullSafe ? '!' : '';
   indent.write('abstract class ${api.name} ');
   indent.scoped('{', '}', () {
-    for (Method func in api.methods) {
+    for (final Method func in api.methods) {
       final bool isAsync = func.isAsynchronous;
       final String returnType =
-          isAsync ? 'Future<${func.returnType}>' : '${func.returnType}';
+          isAsync ? 'Future<${func.returnType}>' : func.returnType;
       final String argSignature =
           func.argType == 'void' ? '' : '${func.argType} arg';
       indent.writeln('$returnType ${func.name}($argSignature);');
     }
     indent.write('static void setup(${api.name}$nullTag api) ');
     indent.scoped('{', '}', () {
-      for (Method func in api.methods) {
+      for (final Method func in api.methods) {
         indent.write('');
         indent.scoped('{', '}', () {
           indent.writeln(
@@ -206,12 +206,12 @@
   );
   indent.writeln('');
   indent.writeln('import \'package:flutter/services.dart\';');
-  for (Class klass in root.classes) {
+  for (final Class klass in root.classes) {
     indent.writeln('');
     sink.write('class ${klass.name} ');
     indent.scoped('{', '}', () {
-      for (Field field in klass.fields) {
-        final String datatype = '${_addGenericTypes(field.dataType, nullTag)}';
+      for (final Field field in klass.fields) {
+        final String datatype = _addGenericTypes(field.dataType, nullTag);
         indent.writeln('$datatype ${field.name};');
       }
       if (klass.fields.isNotEmpty) {
@@ -222,7 +222,7 @@
         indent.writeln(
           'final Map<Object$nullTag, Object$nullTag> pigeonMap = <Object$nullTag, Object$nullTag>{};',
         );
-        for (Field field in klass.fields) {
+        for (final Field field in klass.fields) {
           indent.write('pigeonMap[\'${field.name}\'] = ');
           if (customClassNames.contains(field.dataType)) {
             indent.addln(
@@ -262,7 +262,7 @@
       });
     });
   }
-  for (Api api in root.apis) {
+  for (final Api api in root.apis) {
     indent.writeln('');
     if (api.location == ApiLocation.host) {
       _writeHostApi(opt, indent, api);
@@ -297,7 +297,7 @@
   indent.writeln(
     'import \'${_escapeForDartSingleQuotedString(mainDartFile)}\';',
   );
-  for (Api api in root.apis) {
+  for (final Api api in root.apis) {
     if (api.location == ApiLocation.host && api.dartHostTestHandler != null) {
       final Api mockApi = Api(
         name: api.dartHostTestHandler,
diff --git a/packages/pigeon/lib/generator_tools.dart b/packages/pigeon/lib/generator_tools.dart
index 294962c..1a9c328 100644
--- a/packages/pigeon/lib/generator_tools.dart
+++ b/packages/pigeon/lib/generator_tools.dart
@@ -56,7 +56,7 @@
 
   /// Replaces the newlines and tabs of input and adds it to the stream.
   void format(String input) {
-    for (String line in input.split('\n')) {
+    for (final String line in input.split('\n')) {
       writeln(line.replaceAll('\t', tab));
     }
   }
diff --git a/packages/pigeon/lib/java_generator.dart b/packages/pigeon/lib/java_generator.dart
index 51d21f7..4f3bde4 100644
--- a/packages/pigeon/lib/java_generator.dart
+++ b/packages/pigeon/lib/java_generator.dart
@@ -42,7 +42,7 @@
       '/** Generated interface from Pigeon that represents a handler of messages from Flutter.*/');
   indent.write('public interface ${api.name} ');
   indent.scoped('{', '}', () {
-    for (Method method in api.methods) {
+    for (final Method method in api.methods) {
       final String returnType =
           method.isAsynchronous ? 'void' : method.returnType;
       final List<String> argSignature = <String>[];
@@ -60,7 +60,7 @@
     indent.write(
         'static void setup(BinaryMessenger binaryMessenger, ${api.name} api) ');
     indent.scoped('{', '}', () {
-      for (Method method in api.methods) {
+      for (final Method method in api.methods) {
         final String channelName = makeChannelName(api, method);
         indent.write('');
         indent.scoped('{', '}', () {
@@ -145,7 +145,7 @@
     indent.scoped('{', '}', () {
       indent.writeln('void reply(T reply);');
     });
-    for (Method func in api.methods) {
+    for (final Method func in api.methods) {
       final String channelName = makeChannelName(api, func);
       final String returnType =
           func.returnType == 'void' ? 'Void' : func.returnType;
@@ -242,13 +242,13 @@
       '@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"})');
   indent.write('public class ${options.className} ');
   indent.scoped('{', '}', () {
-    for (Class klass in root.classes) {
+    for (final Class klass in root.classes) {
       indent.addln('');
       indent.writeln(
           '/** Generated class from Pigeon that represents data sent in messages. */');
       indent.write('public static class ${klass.name} ');
       indent.scoped('{', '}', () {
-        for (Field field in klass.fields) {
+        for (final Field field in klass.fields) {
           final HostDatatype hostDatatype =
               getHostDatatype(field, root.classes, _javaTypeForDartType);
           indent.writeln('private ${hostDatatype.datatype} ${field.name};');
@@ -261,7 +261,7 @@
         indent.write('Map<String, Object> toMap() ');
         indent.scoped('{', '}', () {
           indent.writeln('Map<String, Object> toMapResult = new HashMap<>();');
-          for (Field field in klass.fields) {
+          for (final Field field in klass.fields) {
             final HostDatatype hostDatatype =
                 getHostDatatype(field, root.classes, _javaTypeForDartType);
             String toWriteValue = '';
@@ -278,7 +278,7 @@
         indent.write('static ${klass.name} fromMap(Map<String, Object> map) ');
         indent.scoped('{', '}', () {
           indent.writeln('${klass.name} fromMapResult = new ${klass.name}();');
-          for (Field field in klass.fields) {
+          for (final Field field in klass.fields) {
             indent.writeln('Object ${field.name} = map.get("${field.name}");');
             indent.writeln(
                 'fromMapResult.${field.name} = ${_castObject(field, root.classes, field.name)};');
@@ -288,7 +288,7 @@
       });
     }
 
-    for (Api api in root.apis) {
+    for (final Api api in root.apis) {
       indent.addln('');
       if (api.location == ApiLocation.host) {
         _writeHostApi(indent, api);
@@ -297,8 +297,8 @@
       }
     }
 
-    indent.format(
-        '''private static Map<String, Object> wrapError(Exception exception) {
+    indent.format('''
+private static Map<String, Object> wrapError(Exception exception) {
 \tMap<String, Object> errorMap = new HashMap<>();
 \terrorMap.put("${Keys.errorMessage}", exception.toString());
 \terrorMap.put("${Keys.errorCode}", exception.getClass().getSimpleName());
diff --git a/packages/pigeon/lib/objc_generator.dart b/packages/pigeon/lib/objc_generator.dart
index a0ce4ba..30a4b59 100644
--- a/packages/pigeon/lib/objc_generator.dart
+++ b/packages/pigeon/lib/objc_generator.dart
@@ -73,9 +73,9 @@
 
 void _writeClassDeclarations(
     Indent indent, List<Class> classes, String prefix) {
-  for (Class klass in classes) {
+  for (final Class klass in classes) {
     indent.writeln('@interface ${_className(prefix, klass.name)} : NSObject');
-    for (Field field in klass.fields) {
+    for (final Field field in klass.fields) {
       final HostDatatype hostDatatype = getHostDatatype(
           field, classes, _objcTypeForDartType,
           customResolver: (String x) => '${_className(prefix, x)} *');
@@ -95,7 +95,7 @@
 void _writeHostApiDeclaration(Indent indent, Api api, ObjcOptions options) {
   final String apiName = _className(options.prefix, api.name);
   indent.writeln('@protocol $apiName');
-  for (Method func in api.methods) {
+  for (final Method func in api.methods) {
     final String returnTypeName = _className(options.prefix, func.returnType);
     if (func.isAsynchronous) {
       if (func.returnType == 'void') {
@@ -142,7 +142,7 @@
   indent.writeln('@interface $apiName : NSObject');
   indent.writeln(
       '- (instancetype)initWithBinaryMessenger:(id<FlutterBinaryMessenger>)binaryMessenger;');
-  for (Method func in api.methods) {
+  for (final Method func in api.methods) {
     final String returnType = _className(options.prefix, func.returnType);
     final String callbackType = _callbackForType(func.returnType, returnType);
     if (func.argType == 'void') {
@@ -171,7 +171,7 @@
   indent.writeln('NS_ASSUME_NONNULL_BEGIN');
   indent.writeln('');
 
-  for (Class klass in root.classes) {
+  for (final Class klass in root.classes) {
     indent.writeln('@class ${_className(options.prefix, klass.name)};');
   }
 
@@ -179,7 +179,7 @@
 
   _writeClassDeclarations(indent, root.classes, options.prefix);
 
-  for (Api api in root.apis) {
+  for (final Api api in root.apis) {
     if (api.location == ApiLocation.host) {
       _writeHostApiDeclaration(indent, api, options);
     } else if (api.location == ApiLocation.flutter) {
@@ -217,7 +217,7 @@
   indent.write(
       'void ${apiName}Setup(id<FlutterBinaryMessenger> binaryMessenger, id<$apiName> api) ');
   indent.scoped('{', '}', () {
-    for (Method func in api.methods) {
+    for (final Method func in api.methods) {
       indent.write('');
       indent.scoped('{', '}', () {
         indent.writeln('FlutterBasicMessageChannel *channel =');
@@ -319,7 +319,7 @@
     indent.writeln('return self;');
   });
   indent.addln('');
-  for (Method func in api.methods) {
+  for (final Method func in api.methods) {
     final String returnType = _className(options.prefix, func.returnType);
     final String callbackType = _callbackForType(func.returnType, returnType);
 
@@ -379,8 +379,8 @@
   indent.writeln('#endif');
   indent.addln('');
 
-  indent.format(
-      '''static NSDictionary<NSString*, id>* wrapResult(NSDictionary *result, FlutterError *error) {
+  indent.format('''
+static NSDictionary<NSString*, id>* wrapResult(NSDictionary *result, FlutterError *error) {
 \tNSDictionary *errorDict = (NSDictionary *)[NSNull null];
 \tif (error) {
 \t\terrorDict = @{
@@ -396,7 +396,7 @@
 }''');
   indent.addln('');
 
-  for (Class klass in root.classes) {
+  for (final Class klass in root.classes) {
     final String className = _className(options.prefix, klass.name);
     indent.writeln('@interface $className ()');
     indent.writeln('+($className*)fromMap:(NSDictionary*)dict;');
@@ -406,14 +406,14 @@
 
   indent.writeln('');
 
-  for (Class klass in root.classes) {
+  for (final Class klass in root.classes) {
     final String className = _className(options.prefix, klass.name);
     indent.writeln('@implementation $className');
     indent.write('+($className*)fromMap:(NSDictionary*)dict ');
     indent.scoped('{', '}', () {
       const String resultName = 'result';
       indent.writeln('$className* $resultName = [[$className alloc] init];');
-      for (Field field in klass.fields) {
+      for (final Field field in klass.fields) {
         indent.writeln(
             '$resultName.${field.name} = ${_dictGetter(classnames, 'dict', field, options.prefix)};');
         indent.write(
@@ -427,7 +427,7 @@
     indent.write('-(NSDictionary*)toMap ');
     indent.scoped('{', '}', () {
       indent.write('return [NSDictionary dictionaryWithObjectsAndKeys:');
-      for (Field field in klass.fields) {
+      for (final Field field in klass.fields) {
         indent.add(_dictValue(classnames, field) + ', @"${field.name}", ');
       }
       indent.addln('nil];');
@@ -436,7 +436,7 @@
     indent.writeln('');
   }
 
-  for (Api api in root.apis) {
+  for (final Api api in root.apis) {
     if (api.location == ApiLocation.host) {
       _writeHostApiSource(indent, options, api);
     } else if (api.location == ApiLocation.flutter) {
diff --git a/packages/pigeon/lib/pigeon_lib.dart b/packages/pigeon/lib/pigeon_lib.dart
index 22d3871..baa70bd 100644
--- a/packages/pigeon/lib/pigeon_lib.dart
+++ b/packages/pigeon/lib/pigeon_lib.dart
@@ -98,7 +98,7 @@
 }
 
 HostApi _getHostApi(ClassMirror apiMirror) {
-  for (InstanceMirror instance in apiMirror.metadata) {
+  for (final InstanceMirror instance in apiMirror.metadata) {
     if (instance.reflectee is HostApi) {
       return instance.reflectee;
     }
@@ -107,7 +107,7 @@
 }
 
 bool _isFlutterApi(ClassMirror apiMirror) {
-  for (InstanceMirror instance in apiMirror.metadata) {
+  for (final InstanceMirror instance in apiMirror.metadata) {
     if (instance.reflectee is FlutterApi) {
       return true;
     }
@@ -166,7 +166,8 @@
 
   Class _parseClassMirror(ClassMirror klassMirror) {
     final List<Field> fields = <Field>[];
-    for (DeclarationMirror declaration in klassMirror.declarations.values) {
+    for (final DeclarationMirror declaration
+        in klassMirror.declarations.values) {
       if (declaration is VariableMirror) {
         fields.add(Field()
           ..name = MirrorSystem.getName(declaration.simpleName)
@@ -180,7 +181,7 @@
   }
 
   Iterable<Class> _parseClassMirrors(Iterable<ClassMirror> mirrors) sync* {
-    for (ClassMirror mirror in mirrors) {
+    for (final ClassMirror mirror in mirrors) {
       yield _parseClassMirror(mirror);
       final Iterable<ClassMirror> nestedTypes = mirror.declarations.values
           .whereType<VariableMirror>()
@@ -190,7 +191,7 @@
           ///note: This will need to be changed if we support generic types.
           .where((ClassMirror mirror) =>
               !_validTypes.contains(MirrorSystem.getName(mirror.simpleName)));
-      for (Class klass in _parseClassMirrors(nestedTypes)) {
+      for (final Class klass in _parseClassMirrors(nestedTypes)) {
         yield klass;
       }
     }
@@ -198,7 +199,7 @@
 
   Iterable<T> _unique<T, U>(Iterable<T> iter, U Function(T val) getKey) sync* {
     final Set<U> seen = <U>{};
-    for (T val in iter) {
+    for (final T val in iter) {
       if (seen.add(getKey(val))) {
         yield val;
       }
@@ -211,7 +212,7 @@
     final Set<ClassMirror> classes = <ClassMirror>{};
     final List<ClassMirror> apis = <ClassMirror>[];
 
-    for (Type type in types) {
+    for (final Type type in types) {
       final ClassMirror classMirror = reflectClass(type);
       if (_isApi(classMirror)) {
         apis.add(classMirror);
@@ -220,8 +221,9 @@
       }
     }
 
-    for (ClassMirror apiMirror in apis) {
-      for (DeclarationMirror declaration in apiMirror.declarations.values) {
+    for (final ClassMirror apiMirror in apis) {
+      for (final DeclarationMirror declaration
+          in apiMirror.declarations.values) {
         if (declaration is MethodMirror && !declaration.isConstructor) {
           if (!isVoid(declaration.returnType)) {
             classes.add(declaration.returnType);
@@ -237,9 +239,10 @@
         _unique(_parseClassMirrors(classes), (Class x) => x.name).toList();
 
     root.apis = <Api>[];
-    for (ClassMirror apiMirror in apis) {
+    for (final ClassMirror apiMirror in apis) {
       final List<Method> functions = <Method>[];
-      for (DeclarationMirror declaration in apiMirror.declarations.values) {
+      for (final DeclarationMirror declaration
+          in apiMirror.declarations.values) {
         if (declaration is MethodMirror && !declaration.isConstructor) {
           final bool isAsynchronous =
               declaration.metadata.any((InstanceMirror it) {
@@ -337,8 +340,8 @@
     final List<Error> result = <Error>[];
     final List<String> customClasses =
         root.classes.map((Class x) => x.name).toList();
-    for (Class klass in root.classes) {
-      for (Field field in klass.fields) {
+    for (final Class klass in root.classes) {
+      for (final Field field in klass.fields) {
         if (!(_validTypes.contains(field.dataType) ||
             customClasses.contains(field.dataType))) {
           result.add(Error(
@@ -347,8 +350,8 @@
         }
       }
     }
-    for (Api api in root.apis) {
-      for (Method method in api.methods) {
+    for (final Api api in root.apis) {
+      for (final Method method in api.methods) {
         if (_validTypes.contains(method.argType)) {
           result.add(Error(
               message:
@@ -368,8 +371,9 @@
   /// Crawls through the reflection system looking for a configurePigeon method and
   /// executing it.
   static void _executeConfigurePigeon(PigeonOptions options) {
-    for (LibraryMirror library in currentMirrorSystem().libraries.values) {
-      for (DeclarationMirror declaration in library.declarations.values) {
+    for (final LibraryMirror library
+        in currentMirrorSystem().libraries.values) {
+      for (final DeclarationMirror declaration in library.declarations.values) {
         if (declaration is MethodMirror &&
             MirrorSystem.getName(declaration.simpleName) == 'configurePigeon') {
           if (declaration.parameters.length == 1 &&
@@ -410,8 +414,9 @@
       options.javaOptions.className = basenameWithoutExtension(options.javaOut);
     }
 
-    for (LibraryMirror library in currentMirrorSystem().libraries.values) {
-      for (DeclarationMirror declaration in library.declarations.values) {
+    for (final LibraryMirror library
+        in currentMirrorSystem().libraries.values) {
+      for (final DeclarationMirror declaration in library.declarations.values) {
         if (declaration is ClassMirror && _isApi(declaration)) {
           apis.add(declaration.reflectedType);
         }
@@ -420,7 +425,7 @@
 
     if (apis.isNotEmpty) {
       final ParseResults parseResults = pigeon.parse(apis);
-      for (Error err in parseResults.errors) {
+      for (final Error err in parseResults.errors) {
         errors.add(Error(message: err.message, filename: options.input));
       }
       if (options.dartOut != null) {
@@ -473,7 +478,7 @@
 
   /// Print a list of errors to stderr.
   static void printErrors(List<Error> errors) {
-    for (Error err in errors) {
+    for (final Error err in errors) {
       if (err.filename != null) {
         if (err.lineNumber != null) {
           stderr.writeln(
diff --git a/packages/pigeon/mock_handler_tester/test/message.dart b/packages/pigeon/mock_handler_tester/test/message.dart
index b7b97ff..30ccafa 100644
--- a/packages/pigeon/mock_handler_tester/test/message.dart
+++ b/packages/pigeon/mock_handler_tester/test/message.dart
@@ -53,7 +53,7 @@
 
   Object encode() {
     final Map<Object, Object> pigeonMap = <Object, Object>{};
-    pigeonMap['request'] = request == null ? null : request.encode();
+    pigeonMap['request'] = request?.encode();
     return pigeonMap;
   }
 
diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_safe_pigeon.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_safe_pigeon.dart
index 455058d..ef41241 100644
--- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_safe_pigeon.dart
+++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_safe_pigeon.dart
@@ -102,9 +102,9 @@
       );
     } else if (replyMap['error'] != null) {
       final Map<Object?, Object?> error =
-          replyMap['error'] as Map<Object?, Object?>;
+          replyMap['error']! as Map<Object?, Object?>;
       throw PlatformException(
-        code: error['code'] as String,
+        code: error['code']! as String,
         message: error['message'] as String?,
         details: error['details'],
       );
@@ -128,9 +128,9 @@
       );
     } else if (replyMap['error'] != null) {
       final Map<Object?, Object?> error =
-          replyMap['error'] as Map<Object?, Object?>;
+          replyMap['error']! as Map<Object?, Object?>;
       throw PlatformException(
-        code: error['code'] as String,
+        code: error['code']! as String,
         message: error['message'] as String?,
         details: error['details'],
       );
@@ -153,9 +153,9 @@
       );
     } else if (replyMap['error'] != null) {
       final Map<Object?, Object?> error =
-          replyMap['error'] as Map<Object?, Object?>;
+          replyMap['error']! as Map<Object?, Object?>;
       throw PlatformException(
-        code: error['code'] as String,
+        code: error['code']! as String,
         message: error['message'] as String?,
         details: error['details'],
       );
diff --git a/packages/pigeon/platform_tests/ios_unit_tests/lib/main.dart b/packages/pigeon/platform_tests/ios_unit_tests/lib/main.dart
index 27c8c14..e89b0e7 100644
--- a/packages/pigeon/platform_tests/ios_unit_tests/lib/main.dart
+++ b/packages/pigeon/platform_tests/ios_unit_tests/lib/main.dart
@@ -1,9 +1,12 @@
 import 'package:flutter/material.dart';
 
-void main() => runApp(MyApp());
+void main() => runApp(const MyApp());
 
 /// An empty app.
 class MyApp extends StatelessWidget {
+  /// Creates an empty app.
+  const MyApp({Key key}) : super(key: key);
+
   @override
   Widget build(BuildContext context) {
     return Container();
diff --git a/packages/pigeon/test/dart_generator_test.dart b/packages/pigeon/test/dart_generator_test.dart
index 8c16757..4f6fde4 100644
--- a/packages/pigeon/test/dart_generator_test.dart
+++ b/packages/pigeon/test/dart_generator_test.dart
@@ -192,7 +192,7 @@
     final StringBuffer sink = StringBuffer();
     generateDart(DartOptions(), root, sink);
     final String code = sink.toString();
-    expect(code, matches('channel\.send[(]null[)]'));
+    expect(code, matches('channel.send[(]null[)]'));
   });
 
   test('mock dart handler', () {
@@ -230,7 +230,7 @@
     expect(mainCode, isNot(contains('import \'fo\\\'o.dart\';')));
     expect(mainCode, contains('class Api {'));
     expect(mainCode, isNot(contains('abstract class ApiMock')));
-    expect(mainCode, isNot(contains('\.ApiMock\.doSomething')));
+    expect(mainCode, isNot(contains('.ApiMock.doSomething')));
     expect(mainCode, isNot(contains('\'${Keys.result}\': output.encode()')));
     expect(mainCode, isNot(contains('return <Object, Object>{};')));
     generateTestDart(DartOptions(), root, testCodeSink, "fo'o.dart");
@@ -238,7 +238,7 @@
     expect(testCode, contains('import \'fo\\\'o.dart\';'));
     expect(testCode, isNot(contains('class Api {')));
     expect(testCode, contains('abstract class ApiMock'));
-    expect(testCode, isNot(contains('\.ApiMock\.doSomething')));
+    expect(testCode, isNot(contains('.ApiMock.doSomething')));
     expect(testCode, contains('\'${Keys.result}\': output.encode()'));
     expect(testCode, contains('return <Object, Object>{};'));
   });
@@ -308,7 +308,7 @@
     final StringBuffer sink = StringBuffer();
     generateDart(DartOptions(), root, sink);
     final String code = sink.toString();
-    expect(code, isNot(matches('=.\s*doSomething')));
+    expect(code, isNot(matches('=.s*doSomething')));
     expect(code, contains('await api.doSomething('));
     expect(code, isNot(contains('._toMap()')));
   });
@@ -356,6 +356,6 @@
     final StringBuffer sink = StringBuffer();
     generateDart(DartOptions(), root, sink);
     final String code = sink.toString();
-    expect(code, matches('channel\.send[(]null[)]'));
+    expect(code, matches('channel.send[(]null[)]'));
   });
 }
diff --git a/packages/pigeon/test/objc_generator_test.dart b/packages/pigeon/test/objc_generator_test.dart
index 041d811..329f151 100644
--- a/packages/pigeon/test/objc_generator_test.dart
+++ b/packages/pigeon/test/objc_generator_test.dart
@@ -29,7 +29,7 @@
     final StringBuffer sink = StringBuffer();
     generateObjcSource(ObjcOptions(header: 'foo.h'), root, sink);
     final String code = sink.toString();
-    expect(code, contains('#import \"foo.h\"'));
+    expect(code, contains('#import "foo.h"'));
     expect(code, contains('@implementation Foobar'));
   });
 
@@ -53,7 +53,7 @@
     expect(code, contains('@interface Output'));
     expect(code, contains('@protocol Api'));
     expect(code, matches('nullable Output.*doSomething.*Input.*FlutterError'));
-    expect(code, matches('ApiSetup.*\<Api\>.*_Nullable'));
+    expect(code, matches('ApiSetup.*<Api>.*_Nullable'));
   });
 
   test('gen one api source', () {
@@ -122,7 +122,7 @@
     generateObjcSource(ObjcOptions(header: 'foo.h'), root, sink);
     final String code = sink.toString();
     expect(code, contains('@implementation Foobar'));
-    expect(code, contains('result.aBool = dict[@\"aBool\"];'));
+    expect(code, contains('result.aBool = dict[@"aBool"];'));
   });
 
   test('nested class header', () {
@@ -153,9 +153,8 @@
     final StringBuffer sink = StringBuffer();
     generateObjcSource(ObjcOptions(header: 'foo.h'), root, sink);
     final String code = sink.toString();
-    expect(
-        code, contains('result.nested = [Input fromMap:dict[@\"nested\"]];'));
-    expect(code, matches('[self.nested toMap].*@\"nested\"'));
+    expect(code, contains('result.nested = [Input fromMap:dict[@"nested"]];'));
+    expect(code, matches('[self.nested toMap].*@"nested"'));
   });
 
   test('prefix class header', () {
diff --git a/packages/pigeon/test/pigeon_lib_test.dart b/packages/pigeon/test/pigeon_lib_test.dart
index a842beb..457eff0 100644
--- a/packages/pigeon/test/pigeon_lib_test.dart
+++ b/packages/pigeon/test/pigeon_lib_test.dart
@@ -128,7 +128,7 @@
 
     Class input;
     Class output;
-    for (Class klass in root.classes) {
+    for (final Class klass in root.classes) {
       if (klass.name == 'Input1') {
         input = klass;
       } else if (klass.name == 'Output1') {
diff --git a/packages/pigeon/test/version_test.dart b/packages/pigeon/test/version_test.dart
index d8c867b..a586856 100644
--- a/packages/pigeon/test/version_test.dart
+++ b/packages/pigeon/test/version_test.dart
@@ -11,7 +11,7 @@
   test('pigeon version matches pubspec', () {
     final String pubspecPath = '${Directory.current.path}/pubspec.yaml';
     final String pubspec = File(pubspecPath).readAsStringSync();
-    final RegExp regex = RegExp('version:\s*(.*?) #');
+    final RegExp regex = RegExp(r'version:\s*(.*?) #');
     final RegExpMatch match = regex.firstMatch(pubspec);
     expect(match, isNotNull);
     expect(pigeonVersion, match.group(1).trim());
diff --git a/packages/pointer_interceptor/example/lib/main.dart b/packages/pointer_interceptor/example/lib/main.dart
index fd2b539..619380c 100644
--- a/packages/pointer_interceptor/example/lib/main.dart
+++ b/packages/pointer_interceptor/example/lib/main.dart
@@ -42,11 +42,14 @@
 //       ..style.border = 'none';
 
 void main() {
-  runApp(MyApp());
+  runApp(const MyApp());
 }
 
 /// Main app
 class MyApp extends StatelessWidget {
+  /// Creates main app.
+  const MyApp({Key? key}) : super(key: key);
+
   @override
   Widget build(BuildContext context) {
     ui.platformViewRegistry.registerViewFactory(_htmlElementViewType,
@@ -56,7 +59,7 @@
       return wrapper;
     });
 
-    return MaterialApp(
+    return const MaterialApp(
       title: 'Stopping Clicks with some DOM',
       home: MyHomePage(),
     );
@@ -65,6 +68,9 @@
 
 /// First page
 class MyHomePage extends StatefulWidget {
+  /// Creates first page.
+  const MyHomePage({Key? key}) : super(key: key);
+
   @override
   _MyHomePageState createState() => _MyHomePageState();
 }
@@ -186,7 +192,7 @@
 /// Initialize the videoPlayer, then render the corresponding view...
 class HtmlElement extends StatelessWidget {
   /// Constructor
-  const HtmlElement({required this.onClick});
+  const HtmlElement({Key? key, required this.onClick}) : super(key: key);
 
   /// A function to run when the element is clicked
   final Function onClick;
diff --git a/packages/web_benchmarks/lib/src/recorder.dart b/packages/web_benchmarks/lib/src/recorder.dart
index 5c81c2a..f9e6df5 100644
--- a/packages/web_benchmarks/lib/src/recorder.dart
+++ b/packages/web_benchmarks/lib/src/recorder.dart
@@ -548,11 +548,16 @@
   final WidgetBuildRecorder recorder;
 
   @override
-  State<StatefulWidget> createState() =>
-      recorder._hostState = _WidgetBuildRecorderHostState();
+  State<StatefulWidget> createState() => _WidgetBuildRecorderHostState();
 }
 
 class _WidgetBuildRecorderHostState extends State<_WidgetBuildRecorderHost> {
+  @override
+  void initState() {
+    super.initState();
+    widget.recorder._hostState = this;
+  }
+
   // This is just to bypass the @protected on setState.
   void _setStateTrampoline() {
     setState(() {});
@@ -776,9 +781,10 @@
   String toString() {
     final StringBuffer buffer = StringBuffer();
     buffer.writeln(
-        '$name: (samples: $cleanSampleCount clean/$outlierSampleCount outliers/'
-        '${cleanSampleCount + outlierSampleCount} measured/'
-        '${samples.length} total)');
+      '$name: (samples: $cleanSampleCount clean/$outlierSampleCount '
+      'outliers/${cleanSampleCount + outlierSampleCount} '
+      'measured/${samples.length} total)',
+    );
     buffer.writeln(' | average: $average μs');
     buffer.writeln(' | outlier average: $outlierAverage μs');
     buffer.writeln(' | outlier/clean ratio: ${outlierRatio}x');
diff --git a/packages/web_benchmarks/testing/test_app/lib/aboutpage.dart b/packages/web_benchmarks/testing/test_app/lib/aboutpage.dart
index 337f702..5844dfb 100644
--- a/packages/web_benchmarks/testing/test_app/lib/aboutpage.dart
+++ b/packages/web_benchmarks/testing/test_app/lib/aboutpage.dart
@@ -7,6 +7,8 @@
 const ValueKey<String> backKey = ValueKey<String>('backKey');
 
 class AboutPage extends StatelessWidget {
+  const AboutPage({Key key}) : super(key: key);
+
   @override
   Widget build(BuildContext context) {
     return Scaffold(
diff --git a/packages/web_benchmarks/testing/test_app/lib/benchmarks/runner.dart b/packages/web_benchmarks/testing/test_app/lib/benchmarks/runner.dart
index b35bfa9..13daba1 100644
--- a/packages/web_benchmarks/testing/test_app/lib/benchmarks/runner.dart
+++ b/packages/web_benchmarks/testing/test_app/lib/benchmarks/runner.dart
@@ -21,7 +21,7 @@
   @override
   Widget createWidget() {
     Future<void>.delayed(const Duration(milliseconds: 400), automate);
-    return MyApp();
+    return const MyApp();
   }
 
   Future<void> animationStops() async {
diff --git a/packages/web_benchmarks/testing/test_app/lib/main.dart b/packages/web_benchmarks/testing/test_app/lib/main.dart
index c25696b..ad775c9 100644
--- a/packages/web_benchmarks/testing/test_app/lib/main.dart
+++ b/packages/web_benchmarks/testing/test_app/lib/main.dart
@@ -8,10 +8,12 @@
 import 'homepage.dart';
 
 void main() {
-  runApp(MyApp());
+  runApp(const MyApp());
 }
 
 class MyApp extends StatelessWidget {
+  const MyApp({Key key}) : super(key: key);
+
   @override
   Widget build(BuildContext context) {
     return MaterialApp(
@@ -23,7 +25,7 @@
       initialRoute: 'home',
       routes: <String, WidgetBuilder>{
         'home': (_) => const HomePage(title: 'Flutter Demo Home Page'),
-        'about': (_) => AboutPage(),
+        'about': (_) => const AboutPage(),
       },
     );
   }
diff --git a/packages/xdg_directories/lib/xdg_directories.dart b/packages/xdg_directories/lib/xdg_directories.dart
index f5e7e66..fc5d515 100644
--- a/packages/xdg_directories/lib/xdg_directories.dart
+++ b/packages/xdg_directories/lib/xdg_directories.dart
@@ -33,9 +33,8 @@
 @visibleForTesting
 EnvironmentAccessor? get xdgEnvironmentOverride => _xdgEnvironmentOverride;
 EnvironmentAccessor? _xdgEnvironmentOverride;
-EnvironmentAccessor _productionGetEnv =
-    (String value) => Platform.environment[value];
 EnvironmentAccessor _getenv = _productionGetEnv;
+String? _productionGetEnv(String value) => Platform.environment[value];
 
 /// A testing function that replaces the process manager used to run xdg-user-path
 /// with the one supplied.
@@ -156,7 +155,7 @@
     includeParentEnvironment: true,
     stdoutEncoding: utf8,
   );
-  final String path = result.stdout.split('\n')[0];
+  final String path = (result.stdout as String).split('\n')[0];
   return Directory(path);
 }
 
@@ -178,7 +177,7 @@
   final Set<String> result = <String>{};
   final RegExp dirRegExp =
       RegExp(r'^\s*XDG_(?<dirname>[^=]*)_DIR\s*=\s*(?<dir>.*)\s*$');
-  for (String line in contents) {
+  for (final String line in contents) {
     final RegExpMatch? match = dirRegExp.firstMatch(line);
     if (match == null) {
       continue;
diff --git a/packages/xdg_directories/test/xdg_directories_test.dart b/packages/xdg_directories/test/xdg_directories_test.dart
index c082726..9bf5c0f 100644
--- a/packages/xdg_directories/test/xdg_directories_test.dart
+++ b/packages/xdg_directories/test/xdg_directories_test.dart
@@ -98,7 +98,7 @@
     xdg.xdgProcessManager = FakeProcessManager(expected);
     final Set<String> userDirs = xdg.getUserDirectoryNames();
     expect(userDirs, equals(expected.keys.toSet()));
-    for (String key in userDirs) {
+    for (final String key in userDirs) {
       expect(xdg.getUserDirectory(key)!.path, equals(expected[key]),
           reason: 'Path $key value not correct');
     }