Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b57c502

Browse files
authored
Scenario nnbd (#27365)
* Revert "Revert "NNBD migration for scenario_app (#27362)" (#27364)" This reverts commit 57720b2. * analysis issues * no sound null safety because frontend_server is not
1 parent 8846547 commit b57c502

14 files changed

+54
-75
lines changed

testing/scenario_app/lib/main.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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
5+
66
import 'dart:convert';
77
import 'dart:developer' as developer;
88
import 'dart:io';
@@ -27,7 +27,7 @@ void main() {
2727
}
2828

2929
void _handleDriverMessage(Map<String, dynamic> call) {
30-
final String methodName = call['method'] as String;
30+
final String? methodName = call['method'] as String?;
3131
switch (methodName) {
3232
case 'set_scenario':
3333
assert(call['args'] != null);
@@ -39,7 +39,7 @@ void _handleDriverMessage(Map<String, dynamic> call) {
3939
}
4040

4141
Future<void> _handlePlatformMessage(
42-
String name, ByteData data, PlatformMessageResponseCallback callback) async {
42+
String name, ByteData? data, PlatformMessageResponseCallback? callback) async {
4343
if (data != null) {
4444
print('$name = ${utf8.decode(data.buffer.asUint8List())}');
4545
} else {
@@ -48,11 +48,11 @@ Future<void> _handlePlatformMessage(
4848

4949
switch (name) {
5050
case 'driver':
51-
_handleDriverMessage(json.decode(utf8.decode(data.buffer.asUint8List())) as Map<String, dynamic>);
51+
_handleDriverMessage(json.decode(utf8.decode(data!.buffer.asUint8List())) as Map<String, dynamic>);
5252
break;
5353
case 'write_timeline':
5454
final String timelineData = await _getTimelineData();
55-
callback(Uint8List.fromList(utf8.encode(timelineData)).buffer.asByteData());
55+
callback!(Uint8List.fromList(utf8.encode(timelineData)).buffer.asByteData());
5656
break;
5757
default:
5858
currentScenario?.onPlatformMessage(name, data, callback);
@@ -61,7 +61,7 @@ Future<void> _handlePlatformMessage(
6161

6262
Future<String> _getTimelineData() async {
6363
final developer.ServiceProtocolInfo info = await developer.Service.getInfo();
64-
final Uri vmServiceTimelineUri = info.serverUri.resolve('getVMTimeline');
64+
final Uri vmServiceTimelineUri = info.serverUri!.resolve('getVMTimeline');
6565
final Map<String, dynamic> vmServiceTimelineJson = await _getJson(vmServiceTimelineUri);
6666
final Map<String, dynamic> vmServiceResult = vmServiceTimelineJson['result'] as Map<String, dynamic>;
6767
return json.encode(<String, dynamic>{

testing/scenario_app/lib/src/animated_color_square.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
import 'dart:math' as math;
76
import 'dart:ui';
87

@@ -77,19 +76,19 @@ class AnimatedColorSquareScenario extends Scenario {
7776
}
7877

7978
class _NumberSwinger<T extends num> {
80-
_NumberSwinger(this._begin, this._end, [this._current])
79+
_NumberSwinger(this._begin, this._end, [T? current])
8180
: assert(_begin != null),
8281
assert(_end != null),
8382
_up = _begin < _end {
84-
_current ??= _begin;
83+
_current = current ?? _begin;
8584
}
8685

8786
final T _begin;
8887
final T _end;
8988

9089
/// The current value of the swinger.
9190
T get current => _current;
92-
T _current;
91+
late T _current;
9392

9493
bool _up;
9594

testing/scenario_app/lib/src/bogus_font_text.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
import 'dart:ui';
76

87
import 'channel_util.dart';

testing/scenario_app/lib/src/channel_util.dart

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,17 @@
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
6-
75
import 'dart:convert';
86
import 'dart:ui';
97

10-
import 'package:meta/meta.dart';
11-
128
/// Util method to replicate the behavior of a `MethodChannel` in the Flutter
139
/// framework.
1410
void sendJsonMethodCall({
15-
@required PlatformDispatcher dispatcher,
16-
@required String channel,
17-
@required String method,
11+
required PlatformDispatcher dispatcher,
12+
required String channel,
13+
required String method,
1814
dynamic arguments,
19-
PlatformMessageResponseCallback callback,
15+
PlatformMessageResponseCallback? callback,
2016
}) {
2117
sendJsonMessage(
2218
dispatcher: dispatcher,
@@ -30,10 +26,10 @@ void sendJsonMethodCall({
3026

3127
/// Send a JSON message over a channel.
3228
void sendJsonMessage({
33-
@required PlatformDispatcher dispatcher,
34-
@required String channel,
35-
@required Map<String, dynamic> json,
36-
PlatformMessageResponseCallback callback,
29+
required PlatformDispatcher dispatcher,
30+
required String channel,
31+
required Map<String, dynamic> json,
32+
PlatformMessageResponseCallback? callback,
3733
}) {
3834
dispatcher.sendPlatformMessage(
3935
channel,

testing/scenario_app/lib/src/initial_route_reply.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
import 'dart:ui';
76

87
import 'channel_util.dart';

testing/scenario_app/lib/src/locale_initialization.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +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
6-
75
import 'dart:typed_data';
86
import 'dart:ui';
97

testing/scenario_app/lib/src/platform_echo_mixin.dart

Lines changed: 2 additions & 3 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
import 'dart:typed_data';
76
import 'dart:ui';
87

@@ -13,8 +12,8 @@ mixin PlatformEchoMixin on Scenario {
1312
@override
1413
void onPlatformMessage(
1514
String name,
16-
ByteData data,
17-
PlatformMessageResponseCallback callback,
15+
ByteData? data,
16+
PlatformMessageResponseCallback? callback,
1817
) {
1918
window.sendPlatformMessage(name, data, null);
2019
}

testing/scenario_app/lib/src/platform_view.dart

Lines changed: 26 additions & 28 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
import 'dart:convert';
76
import 'dart:io';
87
import 'dart:typed_data';
@@ -33,7 +32,7 @@ class PlatformViewScenario extends Scenario with _BasePlatformViewScenarioMixin
3332
/// Creates the PlatformView scenario.
3433
///
3534
/// The [dispatcher] parameter must not be null.
36-
PlatformViewScenario(PlatformDispatcher dispatcher, String text, { this.id })
35+
PlatformViewScenario(PlatformDispatcher dispatcher, String text, { required this.id })
3736
: assert(dispatcher != null),
3837
super(dispatcher) {
3938
createPlatformView(dispatcher, text, id);
@@ -58,7 +57,7 @@ class NonFullScreenFlutterViewPlatformViewScenario extends Scenario
5857
/// The [dispatcher] parameter must not be null.
5958
NonFullScreenFlutterViewPlatformViewScenario(
6059
PlatformDispatcher dispatcher, String text,
61-
{this.id})
60+
{required this.id})
6261
: assert(dispatcher != null),
6362
super(dispatcher) {
6463
createPlatformView(dispatcher, text, id);
@@ -80,7 +79,7 @@ class PlatformViewNoOverlayIntersectionScenario extends Scenario with _BasePlatf
8079
/// Creates the PlatformView scenario.
8180
///
8281
/// The [dispatcher] parameter must not be null.
83-
PlatformViewNoOverlayIntersectionScenario(PlatformDispatcher dispatcher, String text, { this.id })
82+
PlatformViewNoOverlayIntersectionScenario(PlatformDispatcher dispatcher, String text, { required this.id })
8483
: assert(dispatcher != null),
8584
super(dispatcher) {
8685
createPlatformView(dispatcher, text, id);
@@ -106,7 +105,7 @@ class PlatformViewPartialIntersectionScenario extends Scenario with _BasePlatfor
106105
/// Creates the PlatformView scenario.
107106
///
108107
/// The [dispatcher] parameter must not be null.
109-
PlatformViewPartialIntersectionScenario(PlatformDispatcher dispatcher, String text, { this.id })
108+
PlatformViewPartialIntersectionScenario(PlatformDispatcher dispatcher, String text, { required this.id })
110109
: assert(dispatcher != null),
111110
super(dispatcher) {
112111
createPlatformView(dispatcher, text, id);
@@ -132,7 +131,7 @@ class PlatformViewTwoIntersectingOverlaysScenario extends Scenario with _BasePla
132131
/// Creates the PlatformView scenario.
133132
///
134133
/// The [dispatcher] parameter must not be null.
135-
PlatformViewTwoIntersectingOverlaysScenario(PlatformDispatcher dispatcher, String text, { this.id })
134+
PlatformViewTwoIntersectingOverlaysScenario(PlatformDispatcher dispatcher, String text, { required this.id })
136135
: assert(dispatcher != null),
137136
super(dispatcher) {
138137
createPlatformView(dispatcher, text, id);
@@ -171,7 +170,7 @@ class PlatformViewOneOverlayTwoIntersectingOverlaysScenario extends Scenario wit
171170
/// Creates the PlatformView scenario.
172171
///
173172
/// The [dispatcher] parameter must not be null.
174-
PlatformViewOneOverlayTwoIntersectingOverlaysScenario(PlatformDispatcher dispatcher, String text, { this.id })
173+
PlatformViewOneOverlayTwoIntersectingOverlaysScenario(PlatformDispatcher dispatcher, String text, { required this.id })
175174
: assert(dispatcher != null),
176175
super(dispatcher) {
177176
createPlatformView(dispatcher, text, id);
@@ -215,7 +214,7 @@ class MultiPlatformViewWithoutOverlaysScenario extends Scenario with _BasePlatfo
215214
/// Creates the PlatformView scenario.
216215
///
217216
/// The [dispatcher] parameter must not be null.
218-
MultiPlatformViewWithoutOverlaysScenario(PlatformDispatcher dispatcher, String text, { this.firstId, this.secondId })
217+
MultiPlatformViewWithoutOverlaysScenario(PlatformDispatcher dispatcher, String text, { required this.firstId, required this.secondId })
219218
: assert(dispatcher != null),
220219
super(dispatcher) {
221220
createPlatformView(dispatcher, text, firstId);
@@ -259,7 +258,7 @@ class PlatformViewMaxOverlaysScenario extends Scenario with _BasePlatformViewSce
259258
/// Creates the PlatformView scenario.
260259
///
261260
/// The [dispatcher] parameter must not be null.
262-
PlatformViewMaxOverlaysScenario(PlatformDispatcher dispatcher, String text, { this.id })
261+
PlatformViewMaxOverlaysScenario(PlatformDispatcher dispatcher, String text, { required this.id })
263262
: assert(dispatcher != null),
264263
super(dispatcher) {
265264
createPlatformView(dispatcher, text, id);
@@ -308,7 +307,7 @@ class MultiPlatformViewScenario extends Scenario with _BasePlatformViewScenarioM
308307
/// Creates the PlatformView scenario.
309308
///
310309
/// The [dispatcher] parameter must not be null.
311-
MultiPlatformViewScenario(PlatformDispatcher dispatcher, {this.firstId, this.secondId})
310+
MultiPlatformViewScenario(PlatformDispatcher dispatcher, {required this.firstId, required this.secondId})
312311
: assert(dispatcher != null),
313312
super(dispatcher) {
314313
createPlatformView(dispatcher, 'platform view 1', firstId);
@@ -342,7 +341,7 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario with _BaseP
342341
/// Creates the PlatformView scenario.
343342
///
344343
/// The [dispatcher] parameter must not be null.
345-
MultiPlatformViewBackgroundForegroundScenario(PlatformDispatcher dispatcher, {this.firstId, this.secondId})
344+
MultiPlatformViewBackgroundForegroundScenario(PlatformDispatcher dispatcher, {required this.firstId, required this.secondId})
346345
: assert(dispatcher != null),
347346
super(dispatcher) {
348347
_nextFrame = _firstFrame;
@@ -361,7 +360,7 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario with _BaseP
361360
_nextFrame();
362361
}
363362

364-
VoidCallback _nextFrame;
363+
late VoidCallback _nextFrame;
365364

366365
void _firstFrame() {
367366
final SceneBuilder builder = SceneBuilder();
@@ -407,13 +406,13 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario with _BaseP
407406
@override
408407
void onPlatformMessage(
409408
String name,
410-
ByteData data,
411-
PlatformMessageResponseCallback callback,
409+
ByteData? data,
410+
PlatformMessageResponseCallback? callback,
412411
) {
413412
if (name != 'flutter/lifecycle') {
414413
return;
415414
}
416-
final String message = utf8.decode(data.buffer.asUint8List());
415+
final String message = utf8.decode(data!.buffer.asUint8List());
417416
if (_lastLifecycleState == 'AppLifecycleState.inactive' && message == 'AppLifecycleState.resumed') {
418417
_nextFrame = _secondFrame;
419418
window.scheduleFrame();
@@ -426,7 +425,7 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario with _BaseP
426425
/// Platform view with clip rect.
427426
class PlatformViewClipRectScenario extends Scenario with _BasePlatformViewScenarioMixin {
428427
/// Constructs a platform view with clip rect scenario.
429-
PlatformViewClipRectScenario(PlatformDispatcher dispatcher, String text, { this.id })
428+
PlatformViewClipRectScenario(PlatformDispatcher dispatcher, String text, { required this.id })
430429
: assert(dispatcher != null),
431430
super(dispatcher) {
432431
createPlatformView(dispatcher, text, id);
@@ -524,15 +523,10 @@ class PlatformViewOpacityScenario extends PlatformViewScenario {
524523
/// A simple platform view for testing touch events from iOS.
525524
class PlatformViewForTouchIOSScenario extends Scenario
526525
with _BasePlatformViewScenarioMixin {
527-
528-
int _viewId;
529-
bool _accept;
530-
531-
VoidCallback _nextFrame;
532526
/// Creates the PlatformView scenario.
533527
///
534528
/// The [dispatcher] parameter must not be null.
535-
PlatformViewForTouchIOSScenario(PlatformDispatcher dispatcher, String text, {int id = 0, bool accept, bool rejectUntilTouchesEnded = false})
529+
PlatformViewForTouchIOSScenario(PlatformDispatcher dispatcher, String text, {int id = 0, required bool accept, bool rejectUntilTouchesEnded = false})
536530
: assert(dispatcher != null),
537531
_accept = accept,
538532
_viewId = id,
@@ -545,6 +539,10 @@ class PlatformViewForTouchIOSScenario extends Scenario
545539
_nextFrame = _firstFrame;
546540
}
547541

542+
int _viewId;
543+
bool _accept;
544+
late VoidCallback _nextFrame;
545+
548546
@override
549547
void onBeginFrame(Duration duration) {
550548
_nextFrame();
@@ -587,7 +585,7 @@ class PlatformViewForTouchIOSScenario extends Scenario
587585
window.sendPlatformMessage(
588586
'flutter/platform_views',
589587
message.buffer.asByteData(),
590-
(ByteData response) {},
588+
(ByteData? response) {},
591589
);
592590
}
593591

@@ -622,10 +620,10 @@ class PlatformViewWithContinuousTexture extends PlatformViewScenario {
622620
}
623621

624622
mixin _BasePlatformViewScenarioMixin on Scenario {
625-
int _textureId;
623+
int? _textureId;
626624

627625
bool get usesAndroidHybridComposition {
628-
return (scenarioParams['use_android_view'] as bool) == true;
626+
return (scenarioParams['use_android_view'] as bool?) == true;
629627
}
630628

631629
/// Construct the platform view related scenario
@@ -702,7 +700,7 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
702700
dispatcher.sendPlatformMessage(
703701
'flutter/platform_views',
704702
message.buffer.asByteData(),
705-
(ByteData response) {
703+
(ByteData? response) {
706704
if (response != null && Platform.isAndroid && !usesAndroidHybridComposition) {
707705
// Envelope.
708706
_textureId = response.getUint8(0);
@@ -723,7 +721,7 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
723721
if (usesAndroidHybridComposition) {
724722
sceneBuilder.addPlatformView(viewId, width: width, height: height);
725723
} else if (_textureId != null) {
726-
sceneBuilder.addTexture(_textureId, width: width, height: height);
724+
sceneBuilder.addTexture(_textureId!, width: width, height: height);
727725
}
728726
} else {
729727
throw UnsupportedError('Platform ${Platform.operatingSystem} is not supported');
@@ -734,7 +732,7 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
734732
void finishBuilderByAddingPlatformViewAndPicture(
735733
SceneBuilder sceneBuilder,
736734
int viewId, {
737-
Offset overlayOffset,
735+
Offset? overlayOffset,
738736
}) {
739737
overlayOffset ??= const Offset(50, 50);
740738
_addPlatformViewToScene(

0 commit comments

Comments
 (0)