diff --git a/dev/benchmarks/microbenchmarks/lib/common.dart b/dev/benchmarks/microbenchmarks/lib/common.dart index 62a08fd467..b503280bc3 100644 --- a/dev/benchmarks/microbenchmarks/lib/common.dart +++ b/dev/benchmarks/microbenchmarks/lib/common.dart @@ -4,8 +4,6 @@ import 'dart:convert' show json; -import 'package:meta/meta.dart'; - /// This class knows how to format benchmark results for machine and human /// consumption. /// @@ -31,7 +29,7 @@ class BenchmarkResultPrinter { /// result value. [unit] is the unit of measurement, such as "ms", "km", "h". /// [name] is a computer-readable name of the result used as a key in the JSON /// serialization of the results. - void addResult({ @required String description, @required double value, @required String unit, @required String name }) { + void addResult({ required String description, required double value, required String unit, required String name }) { _results.add(_BenchmarkResult(description, value, unit, name)); } diff --git a/dev/benchmarks/microbenchmarks/lib/foundation/all_elements_bench.dart b/dev/benchmarks/microbenchmarks/lib/foundation/all_elements_bench.dart index 0e715d541e..17029d141e 100644 --- a/dev/benchmarks/microbenchmarks/lib/foundation/all_elements_bench.dart +++ b/dev/benchmarks/microbenchmarks/lib/foundation/all_elements_bench.dart @@ -44,24 +44,24 @@ Future main() async { // Wait for frame rendering to stabilize. for (int i = 0; i < 5; i++) { - await SchedulerBinding.instance.endOfFrame; + await SchedulerBinding.instance?.endOfFrame; } final Stopwatch watch = Stopwatch(); - print('flutter_test allElements benchmark... (${WidgetsBinding.instance.renderViewElement})'); + print('flutter_test allElements benchmark... (${WidgetsBinding.instance?.renderViewElement})'); // Make sure we get enough elements to process for consistent benchmark runs - int elementCount = collectAllElementsFrom(WidgetsBinding.instance.renderViewElement, skipOffstage: false).length; + int elementCount = collectAllElementsFrom(WidgetsBinding.instance!.renderViewElement!, skipOffstage: false).length; while (elementCount < 2458) { await Future.delayed(Duration.zero); - elementCount = collectAllElementsFrom(WidgetsBinding.instance.renderViewElement, skipOffstage: false).length; + elementCount = collectAllElementsFrom(WidgetsBinding.instance!.renderViewElement!, skipOffstage: false).length; } print('element count: $elementCount'); watch.start(); for (int i = 0; i < _kNumIters; i += 1) { final List allElements = collectAllElementsFrom( - WidgetsBinding.instance.renderViewElement, + WidgetsBinding.instance!.renderViewElement!, skipOffstage: false, ).toList(); allElements.clear(); diff --git a/dev/benchmarks/microbenchmarks/lib/geometry/curves_bench.dart b/dev/benchmarks/microbenchmarks/lib/geometry/curves_bench.dart index 7d403200ba..b373d21bd5 100644 --- a/dev/benchmarks/microbenchmarks/lib/geometry/curves_bench.dart +++ b/dev/benchmarks/microbenchmarks/lib/geometry/curves_bench.dart @@ -9,7 +9,7 @@ import '../common.dart'; const int _kNumIters = 10000; -void _testCurve(Curve curve, {String name, String description, BenchmarkResultPrinter printer}) { +void _testCurve(Curve curve, {required String name, required String description, required BenchmarkResultPrinter printer}) { final Stopwatch watch = Stopwatch(); print('$description benchmark...'); watch.start(); diff --git a/dev/benchmarks/microbenchmarks/lib/gestures/apps/button_matrix_app.dart b/dev/benchmarks/microbenchmarks/lib/gestures/apps/button_matrix_app.dart index 194ee5ec4e..ca947ddb32 100644 --- a/dev/benchmarks/microbenchmarks/lib/gestures/apps/button_matrix_app.dart +++ b/dev/benchmarks/microbenchmarks/lib/gestures/apps/button_matrix_app.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; class ButtonMatrixApp extends StatefulWidget { - const ButtonMatrixApp({Key key}) : super(key: key); + const ButtonMatrixApp({Key? key}) : super(key: key); @override ButtonMatrixAppState createState() => ButtonMatrixAppState(); diff --git a/dev/benchmarks/microbenchmarks/lib/gestures/velocity_tracker_bench.dart b/dev/benchmarks/microbenchmarks/lib/gestures/velocity_tracker_bench.dart index ebb66307be..d77bc04f87 100644 --- a/dev/benchmarks/microbenchmarks/lib/gestures/velocity_tracker_bench.dart +++ b/dev/benchmarks/microbenchmarks/lib/gestures/velocity_tracker_bench.dart @@ -10,7 +10,7 @@ import 'data/velocity_tracker_data.dart'; const int _kNumIters = 10000; class TrackerBenchmark { - TrackerBenchmark({ this.name, this.tracker }); + TrackerBenchmark({required this.name, required this.tracker }); final VelocityTracker tracker; final String name; diff --git a/dev/benchmarks/microbenchmarks/lib/language/sync_star_semantics_bench.dart b/dev/benchmarks/microbenchmarks/lib/language/sync_star_semantics_bench.dart index a11a6422d8..db4472f18d 100644 --- a/dev/benchmarks/microbenchmarks/lib/language/sync_star_semantics_bench.dart +++ b/dev/benchmarks/microbenchmarks/lib/language/sync_star_semantics_bench.dart @@ -80,7 +80,7 @@ String consumeSpan(Iterable items) { Iterable combineSemanticsInfoSyncStar(List inputs) sync* { String workingText = ''; - String workingLabel; + String? workingLabel; for (final InlineSpanSemanticsInformation info in inputs) { if (info.requiresOwnNode) { if (workingText != null) { @@ -92,8 +92,9 @@ Iterable combineSemanticsInfoSyncStar(List combineSemanticsInfoSyncStar(List combineSemanticsInfoList(List inputs) { String workingText = ''; - String workingLabel; + String? workingLabel; final List result = []; for (final InlineSpanSemanticsInformation info in inputs) { if (info.requiresOwnNode) { @@ -121,8 +122,9 @@ Iterable combineSemanticsInfoList(List main() async { // Time how long each frame takes cpuWatch.reset(); - while (SchedulerBinding.instance.hasScheduledFrame) { + while (SchedulerBinding.instance!.hasScheduledFrame) { await tester.pump(); totalSubsequentFramesIterationCount += 1; } diff --git a/dev/benchmarks/microbenchmarks/lib/stocks/layout_bench.dart b/dev/benchmarks/microbenchmarks/lib/stocks/layout_bench.dart index 80e5c30d0b..ade6023ba8 100644 --- a/dev/benchmarks/microbenchmarks/lib/stocks/layout_bench.dart +++ b/dev/benchmarks/microbenchmarks/lib/stocks/layout_bench.dart @@ -33,18 +33,18 @@ Future main() async { final TestViewConfiguration big = TestViewConfiguration( size: const Size(360.0, 640.0), - window: RendererBinding.instance.window, + window: RendererBinding.instance?.window, ); final TestViewConfiguration small = TestViewConfiguration( size: const Size(355.0, 635.0), - window: RendererBinding.instance.window, + window: RendererBinding.instance?.window, ); - final RenderView renderView = WidgetsBinding.instance.renderView; + final RenderView? renderView = WidgetsBinding.instance?.renderView; binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.benchmark; watch.start(); while (watch.elapsed < kBenchmarkTime) { - renderView.configuration = iterations.isEven ? big : small; + renderView?.configuration = iterations.isEven ? big : small; await tester.pumpBenchmark(Duration(milliseconds: iterations * 16)); iterations += 1; } diff --git a/dev/benchmarks/microbenchmarks/pubspec.yaml b/dev/benchmarks/microbenchmarks/pubspec.yaml index ae82c5eac0..d896e3b65c 100644 --- a/dev/benchmarks/microbenchmarks/pubspec.yaml +++ b/dev/benchmarks/microbenchmarks/pubspec.yaml @@ -2,7 +2,7 @@ name: microbenchmarks description: Small benchmarks for very specific parts of the Flutter framework. environment: - sdk: ">=2.0.0-dev.68.0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: meta: 1.4.0