Skip to content

Commit 49de01c

Browse files
authored
Migrate some benchmarks to NNBD (flutter#75023)
1 parent 87b0436 commit 49de01c

File tree

7 files changed

+21
-28
lines changed

7 files changed

+21
-28
lines changed

dev/benchmarks/platform_views_layout/lib/main.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ void main() {
1515

1616
class PlatformViewApp extends StatefulWidget {
1717
const PlatformViewApp({
18-
Key key
18+
Key? key,
1919
}) : super(key: key);
2020

2121
@override
2222
PlatformViewAppState createState() => PlatformViewAppState();
23-
24-
static PlatformViewAppState of(BuildContext context) => context.findAncestorStateOfType<PlatformViewAppState>();
2523
}
2624

2725
class PlatformViewAppState extends State<PlatformViewApp> {
@@ -42,7 +40,7 @@ class PlatformViewAppState extends State<PlatformViewApp> {
4240
}
4341

4442
class PlatformViewLayout extends StatelessWidget {
45-
const PlatformViewLayout({ Key key }) : super(key: key);
43+
const PlatformViewLayout({ Key? key }) : super(key: key);
4644

4745
@override
4846
Widget build(BuildContext context) {
@@ -72,12 +70,12 @@ class PlatformViewLayout extends StatelessWidget {
7270
}
7371

7472
class DummyPlatformView extends StatelessWidget {
75-
const DummyPlatformView({Key key}) : super(key: key);
73+
const DummyPlatformView({Key? key}) : super(key: key);
7674

7775
@override
7876
Widget build(BuildContext context) {
7977
const String viewType = 'benchmarks/platform_views_layout/DummyPlatformView';
80-
Widget nativeView;
78+
late Widget nativeView;
8179
if (Platform.isIOS) {
8280
nativeView = const UiKitView(
8381
viewType: viewType,
@@ -98,15 +96,15 @@ class DummyPlatformView extends StatelessWidget {
9896
}
9997

10098
class RotationContainer extends StatefulWidget {
101-
const RotationContainer({Key key}) : super(key: key);
99+
const RotationContainer({Key? key}) : super(key: key);
102100

103101
@override
104102
_RotationContainerState createState() => _RotationContainerState();
105103
}
106104

107105
class _RotationContainerState extends State<RotationContainer>
108106
with SingleTickerProviderStateMixin {
109-
AnimationController _rotationController;
107+
late AnimationController _rotationController;
110108

111109
@override
112110
void initState() {

dev/benchmarks/platform_views_layout/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: platform_views_layout
22
description: A benchmark for platform views.
33

44
environment:
5-
sdk: ">=2.2.0 <3.0.0"
5+
sdk: ">=2.12.0-0 <3.0.0"
66

77
dependencies:
88
flutter:

dev/benchmarks/platform_views_layout/test_driver/scroll_perf_test.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
77

88
void main() {
99
group('scrolling performance test', () {
10-
FlutterDriver driver;
10+
late FlutterDriver driver;
1111

1212
setUpAll(() async {
1313
driver = await FlutterDriver.connect();
@@ -16,8 +16,7 @@ void main() {
1616
});
1717

1818
tearDownAll(() async {
19-
if (driver != null)
20-
driver.close();
19+
driver.close();
2120
});
2221

2322
Future<void> testScrollPerf(String listKey, String summaryName) async {

dev/benchmarks/platform_views_layout_hybrid_composition/lib/android_platform_view.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ class AndroidPlatformView extends StatelessWidget {
1212
/// Creates a platform view for Android, which is rendered as a
1313
/// native view.
1414
const AndroidPlatformView({
15-
Key key,
16-
@required this.viewType,
17-
}) : assert(viewType != null),
18-
super(key: key);
15+
Key? key,
16+
required this.viewType,
17+
}) : super(key: key);
1918

2019
/// The unique identifier for the view type to be embedded by this widget.
2120
///

dev/benchmarks/platform_views_layout_hybrid_composition/lib/main.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ void main() {
1919

2020
class PlatformViewApp extends StatefulWidget {
2121
const PlatformViewApp({
22-
Key key
22+
Key? key
2323
}) : super(key: key);
2424

2525
@override
2626
PlatformViewAppState createState() => PlatformViewAppState();
27-
28-
static PlatformViewAppState of(BuildContext context) => context.findAncestorStateOfType<PlatformViewAppState>();
2927
}
3028

3129
class PlatformViewAppState extends State<PlatformViewApp> {
@@ -46,7 +44,7 @@ class PlatformViewAppState extends State<PlatformViewApp> {
4644
}
4745

4846
class PlatformViewLayout extends StatelessWidget {
49-
const PlatformViewLayout({ Key key }) : super(key: key);
47+
const PlatformViewLayout({ Key? key }) : super(key: key);
5048

5149
@override
5250
Widget build(BuildContext context) {
@@ -76,12 +74,12 @@ class PlatformViewLayout extends StatelessWidget {
7674
}
7775

7876
class DummyPlatformView extends StatelessWidget {
79-
const DummyPlatformView({Key key}) : super(key: key);
77+
const DummyPlatformView({Key? key}) : super(key: key);
8078

8179
@override
8280
Widget build(BuildContext context) {
8381
const String viewType = 'benchmarks/platform_views_layout_hybrid_composition/DummyPlatformView';
84-
Widget nativeView;
82+
late Widget nativeView;
8583
if (Platform.isIOS) {
8684
nativeView = const UiKitView(
8785
viewType: viewType,
@@ -103,15 +101,15 @@ class DummyPlatformView extends StatelessWidget {
103101
}
104102

105103
class RotationContainer extends StatefulWidget {
106-
const RotationContainer({Key key}) : super(key: key);
104+
const RotationContainer({Key? key}) : super(key: key);
107105

108106
@override
109107
_RotationContainerState createState() => _RotationContainerState();
110108
}
111109

112110
class _RotationContainerState extends State<RotationContainer>
113111
with SingleTickerProviderStateMixin {
114-
AnimationController _rotationController;
112+
late AnimationController _rotationController;
115113

116114
@override
117115
void initState() {

dev/benchmarks/platform_views_layout_hybrid_composition/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: platform_views_layout_hybrid_composition
22
description: A benchmark for platform views, using hybrid composition on android.
33

44
environment:
5-
sdk: ">=2.2.0 <3.0.0"
5+
sdk: ">=2.12.0-0 <3.0.0"
66

77
dependencies:
88
flutter:

dev/benchmarks/platform_views_layout_hybrid_composition/test_driver/scroll_perf_test.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
77

88
void main() {
99
group('scrolling performance test', () {
10-
FlutterDriver driver;
10+
late FlutterDriver driver;
1111

1212
setUpAll(() async {
1313
driver = await FlutterDriver.connect();
@@ -16,8 +16,7 @@ void main() {
1616
});
1717

1818
tearDownAll(() async {
19-
if (driver != null)
20-
driver.close();
19+
driver.close();
2120
});
2221

2322
Future<void> testScrollPerf(String listKey, String summaryName) async {

0 commit comments

Comments
 (0)