Skip to content

Commit de74f8a

Browse files
authored
migrate web engine implementation to null-safe Dart (flutter#19172)
Migrate dart:_engine to null safe dart
1 parent 220a831 commit de74f8a

File tree

113 files changed

+3162
-3202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+3162
-3202
lines changed

lib/web_ui/build.canvaskit.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ targets:
1010
compiler: dart2js
1111
dart2js_args:
1212
- --no-minify
13+
- --disable-inlining
1314
- --enable-asserts
1415
- --enable-experiment=non-nullable
1516
- --no-sound-null-safety

lib/web_ui/build.html.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ targets:
99
compiler: dart2js
1010
dart2js_args:
1111
- --no-minify
12+
- --disable-inlining
1213
- --enable-asserts
1314
- --enable-experiment=non-nullable
1415
- --no-sound-null-safety

lib/web_ui/lib/src/engine.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.6
65
library engine;
76

87
import 'dart:async';

lib/web_ui/lib/src/engine/alarm_clock.dart

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.6
65
part of engine;
76

87
/// A function that returns current system time.
@@ -24,13 +23,13 @@ class AlarmClock {
2423
final TimestampFunction _timestampFunction;
2524

2625
/// The underlying timer used to schedule the callback.
27-
Timer _timer;
26+
Timer? _timer;
2827

2928
/// Current target time the [callback] is scheduled for.
30-
DateTime _datetime;
29+
DateTime? _datetime;
3130

3231
/// The callback called when the alarm goes off.
33-
ui.VoidCallback callback;
32+
late ui.VoidCallback callback;
3433

3534
/// The time when the alarm clock will go off.
3635
///
@@ -39,8 +38,8 @@ class AlarmClock {
3938
/// If the value is updated before an already scheduled timer goes off, the
4039
/// previous time will not call the [callback]. Think of the updating this
4140
/// value as "changing your mind" about when you want the next timer to fire.
42-
DateTime get datetime => _datetime;
43-
set datetime(DateTime value) {
41+
DateTime? get datetime => _datetime;
42+
set datetime(DateTime? value) {
4443
if (value == _datetime) {
4544
return;
4645
}
@@ -72,7 +71,7 @@ class AlarmClock {
7271
} else {
7372
assert(_datetime != null,
7473
'We can only have a timer if there is a non-null datetime');
75-
if (_datetime.isAfter(value)) {
74+
if (_datetime!.isAfter(value)) {
7675
// This is the case when the value moves the target time to an earlier
7776
// point. Because there is no way to reconfigure an existing timer, we
7877
// must cancel the old timer and schedule a new one.
@@ -89,7 +88,7 @@ class AlarmClock {
8988

9089
void _cancelTimer() {
9190
if (_timer != null) {
92-
_timer.cancel();
91+
_timer!.cancel();
9392
_timer = null;
9493
}
9594
}
@@ -100,12 +99,12 @@ class AlarmClock {
10099
final DateTime now = _timestampFunction();
101100
// We use the "not before" logic instead of "is after" because we may have
102101
// zero difference between now and _datetime.
103-
if (!now.isBefore(_datetime)) {
102+
if (!now.isBefore(_datetime!)) {
104103
_timer = null;
105104
callback();
106105
} else {
107106
// The timer fired before the target date. We need to reschedule.
108-
_timer = Timer(_datetime.difference(now), _timerDidFire);
107+
_timer = Timer(_datetime!.difference(now), _timerDidFire);
109108
}
110109
}
111110
}

lib/web_ui/lib/src/engine/assets.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.6
65
part of engine;
76

87
/// This class downloads assets over the network.
@@ -17,10 +16,10 @@ class AssetManager {
1716

1817
const AssetManager({this.assetsDir = _defaultAssetsDir});
1918

20-
String get _baseUrl {
19+
String? get _baseUrl {
2120
return html.window.document
2221
.querySelectorAll('meta')
23-
.whereType<html.MetaElement>()
22+
.whereType<html.MetaElement?>()
2423
.firstWhere((dynamic e) => e.name == 'assetBase', orElse: () => null)
2524
?.content;
2625
}
@@ -58,7 +57,7 @@ class AssetManager {
5857
final ByteBuffer response = request.response;
5958
return response.asByteData();
6059
} on html.ProgressEvent catch (e) {
61-
final html.EventTarget target = e.target;
60+
final html.EventTarget? target = e.target;
6261
if (target is html.HttpRequest) {
6362
if (target.status == 404 && asset == 'AssetManifest.json') {
6463
html.window.console

0 commit comments

Comments
 (0)