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
65import 'dart:convert' ;
76import 'dart:io' ;
87import '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.
427426class 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.
525524class 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
624622mixin _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