Scenario nnbd (flutter/engine#27365)
* Revert "Revert "NNBD migration for scenario_app (#27362)" (#27364)"
This reverts commit 919219937b.
* analysis issues
* no sound null safety because frontend_server is not
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.6
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:developer' as developer;
|
import 'dart:developer' as developer;
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
@@ -27,7 +27,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handleDriverMessage(Map<String, dynamic> call) {
|
void _handleDriverMessage(Map<String, dynamic> call) {
|
||||||
final String methodName = call['method'] as String;
|
final String? methodName = call['method'] as String?;
|
||||||
switch (methodName) {
|
switch (methodName) {
|
||||||
case 'set_scenario':
|
case 'set_scenario':
|
||||||
assert(call['args'] != null);
|
assert(call['args'] != null);
|
||||||
@@ -39,7 +39,7 @@ void _handleDriverMessage(Map<String, dynamic> call) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _handlePlatformMessage(
|
Future<void> _handlePlatformMessage(
|
||||||
String name, ByteData data, PlatformMessageResponseCallback callback) async {
|
String name, ByteData? data, PlatformMessageResponseCallback? callback) async {
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
print('$name = ${utf8.decode(data.buffer.asUint8List())}');
|
print('$name = ${utf8.decode(data.buffer.asUint8List())}');
|
||||||
} else {
|
} else {
|
||||||
@@ -48,11 +48,11 @@ Future<void> _handlePlatformMessage(
|
|||||||
|
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'driver':
|
case 'driver':
|
||||||
_handleDriverMessage(json.decode(utf8.decode(data.buffer.asUint8List())) as Map<String, dynamic>);
|
_handleDriverMessage(json.decode(utf8.decode(data!.buffer.asUint8List())) as Map<String, dynamic>);
|
||||||
break;
|
break;
|
||||||
case 'write_timeline':
|
case 'write_timeline':
|
||||||
final String timelineData = await _getTimelineData();
|
final String timelineData = await _getTimelineData();
|
||||||
callback(Uint8List.fromList(utf8.encode(timelineData)).buffer.asByteData());
|
callback!(Uint8List.fromList(utf8.encode(timelineData)).buffer.asByteData());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
currentScenario?.onPlatformMessage(name, data, callback);
|
currentScenario?.onPlatformMessage(name, data, callback);
|
||||||
@@ -61,7 +61,7 @@ Future<void> _handlePlatformMessage(
|
|||||||
|
|
||||||
Future<String> _getTimelineData() async {
|
Future<String> _getTimelineData() async {
|
||||||
final developer.ServiceProtocolInfo info = await developer.Service.getInfo();
|
final developer.ServiceProtocolInfo info = await developer.Service.getInfo();
|
||||||
final Uri vmServiceTimelineUri = info.serverUri.resolve('getVMTimeline');
|
final Uri vmServiceTimelineUri = info.serverUri!.resolve('getVMTimeline');
|
||||||
final Map<String, dynamic> vmServiceTimelineJson = await _getJson(vmServiceTimelineUri);
|
final Map<String, dynamic> vmServiceTimelineJson = await _getJson(vmServiceTimelineUri);
|
||||||
final Map<String, dynamic> vmServiceResult = vmServiceTimelineJson['result'] as Map<String, dynamic>;
|
final Map<String, dynamic> vmServiceResult = vmServiceTimelineJson['result'] as Map<String, dynamic>;
|
||||||
return json.encode(<String, dynamic>{
|
return json.encode(<String, dynamic>{
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.6
|
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
@@ -77,11 +76,11 @@ class AnimatedColorSquareScenario extends Scenario {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _NumberSwinger<T extends num> {
|
class _NumberSwinger<T extends num> {
|
||||||
_NumberSwinger(this._begin, this._end, [this._current])
|
_NumberSwinger(this._begin, this._end, [T? current])
|
||||||
: assert(_begin != null),
|
: assert(_begin != null),
|
||||||
assert(_end != null),
|
assert(_end != null),
|
||||||
_up = _begin < _end {
|
_up = _begin < _end {
|
||||||
_current ??= _begin;
|
_current = current ?? _begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
final T _begin;
|
final T _begin;
|
||||||
@@ -89,7 +88,7 @@ class _NumberSwinger<T extends num> {
|
|||||||
|
|
||||||
/// The current value of the swinger.
|
/// The current value of the swinger.
|
||||||
T get current => _current;
|
T get current => _current;
|
||||||
T _current;
|
late T _current;
|
||||||
|
|
||||||
bool _up;
|
bool _up;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.6
|
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'channel_util.dart';
|
import 'channel_util.dart';
|
||||||
|
|||||||
@@ -2,21 +2,17 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.6
|
|
||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
|
|
||||||
/// Util method to replicate the behavior of a `MethodChannel` in the Flutter
|
/// Util method to replicate the behavior of a `MethodChannel` in the Flutter
|
||||||
/// framework.
|
/// framework.
|
||||||
void sendJsonMethodCall({
|
void sendJsonMethodCall({
|
||||||
@required PlatformDispatcher dispatcher,
|
required PlatformDispatcher dispatcher,
|
||||||
@required String channel,
|
required String channel,
|
||||||
@required String method,
|
required String method,
|
||||||
dynamic arguments,
|
dynamic arguments,
|
||||||
PlatformMessageResponseCallback callback,
|
PlatformMessageResponseCallback? callback,
|
||||||
}) {
|
}) {
|
||||||
sendJsonMessage(
|
sendJsonMessage(
|
||||||
dispatcher: dispatcher,
|
dispatcher: dispatcher,
|
||||||
@@ -30,10 +26,10 @@ void sendJsonMethodCall({
|
|||||||
|
|
||||||
/// Send a JSON message over a channel.
|
/// Send a JSON message over a channel.
|
||||||
void sendJsonMessage({
|
void sendJsonMessage({
|
||||||
@required PlatformDispatcher dispatcher,
|
required PlatformDispatcher dispatcher,
|
||||||
@required String channel,
|
required String channel,
|
||||||
@required Map<String, dynamic> json,
|
required Map<String, dynamic> json,
|
||||||
PlatformMessageResponseCallback callback,
|
PlatformMessageResponseCallback? callback,
|
||||||
}) {
|
}) {
|
||||||
dispatcher.sendPlatformMessage(
|
dispatcher.sendPlatformMessage(
|
||||||
channel,
|
channel,
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.6
|
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'channel_util.dart';
|
import 'channel_util.dart';
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.6
|
|
||||||
|
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.6
|
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
@@ -13,8 +12,8 @@ mixin PlatformEchoMixin on Scenario {
|
|||||||
@override
|
@override
|
||||||
void onPlatformMessage(
|
void onPlatformMessage(
|
||||||
String name,
|
String name,
|
||||||
ByteData data,
|
ByteData? data,
|
||||||
PlatformMessageResponseCallback callback,
|
PlatformMessageResponseCallback? callback,
|
||||||
) {
|
) {
|
||||||
window.sendPlatformMessage(name, data, null);
|
window.sendPlatformMessage(name, data, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.6
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
@@ -33,7 +32,7 @@ class PlatformViewScenario extends Scenario with _BasePlatformViewScenarioMixin
|
|||||||
/// Creates the PlatformView scenario.
|
/// Creates the PlatformView scenario.
|
||||||
///
|
///
|
||||||
/// The [dispatcher] parameter must not be null.
|
/// The [dispatcher] parameter must not be null.
|
||||||
PlatformViewScenario(PlatformDispatcher dispatcher, String text, { this.id })
|
PlatformViewScenario(PlatformDispatcher dispatcher, String text, { required this.id })
|
||||||
: assert(dispatcher != null),
|
: assert(dispatcher != null),
|
||||||
super(dispatcher) {
|
super(dispatcher) {
|
||||||
createPlatformView(dispatcher, text, id);
|
createPlatformView(dispatcher, text, id);
|
||||||
@@ -58,7 +57,7 @@ class NonFullScreenFlutterViewPlatformViewScenario extends Scenario
|
|||||||
/// The [dispatcher] parameter must not be null.
|
/// The [dispatcher] parameter must not be null.
|
||||||
NonFullScreenFlutterViewPlatformViewScenario(
|
NonFullScreenFlutterViewPlatformViewScenario(
|
||||||
PlatformDispatcher dispatcher, String text,
|
PlatformDispatcher dispatcher, String text,
|
||||||
{this.id})
|
{required this.id})
|
||||||
: assert(dispatcher != null),
|
: assert(dispatcher != null),
|
||||||
super(dispatcher) {
|
super(dispatcher) {
|
||||||
createPlatformView(dispatcher, text, id);
|
createPlatformView(dispatcher, text, id);
|
||||||
@@ -80,7 +79,7 @@ class PlatformViewNoOverlayIntersectionScenario extends Scenario with _BasePlatf
|
|||||||
/// Creates the PlatformView scenario.
|
/// Creates the PlatformView scenario.
|
||||||
///
|
///
|
||||||
/// The [dispatcher] parameter must not be null.
|
/// The [dispatcher] parameter must not be null.
|
||||||
PlatformViewNoOverlayIntersectionScenario(PlatformDispatcher dispatcher, String text, { this.id })
|
PlatformViewNoOverlayIntersectionScenario(PlatformDispatcher dispatcher, String text, { required this.id })
|
||||||
: assert(dispatcher != null),
|
: assert(dispatcher != null),
|
||||||
super(dispatcher) {
|
super(dispatcher) {
|
||||||
createPlatformView(dispatcher, text, id);
|
createPlatformView(dispatcher, text, id);
|
||||||
@@ -106,7 +105,7 @@ class PlatformViewPartialIntersectionScenario extends Scenario with _BasePlatfor
|
|||||||
/// Creates the PlatformView scenario.
|
/// Creates the PlatformView scenario.
|
||||||
///
|
///
|
||||||
/// The [dispatcher] parameter must not be null.
|
/// The [dispatcher] parameter must not be null.
|
||||||
PlatformViewPartialIntersectionScenario(PlatformDispatcher dispatcher, String text, { this.id })
|
PlatformViewPartialIntersectionScenario(PlatformDispatcher dispatcher, String text, { required this.id })
|
||||||
: assert(dispatcher != null),
|
: assert(dispatcher != null),
|
||||||
super(dispatcher) {
|
super(dispatcher) {
|
||||||
createPlatformView(dispatcher, text, id);
|
createPlatformView(dispatcher, text, id);
|
||||||
@@ -132,7 +131,7 @@ class PlatformViewTwoIntersectingOverlaysScenario extends Scenario with _BasePla
|
|||||||
/// Creates the PlatformView scenario.
|
/// Creates the PlatformView scenario.
|
||||||
///
|
///
|
||||||
/// The [dispatcher] parameter must not be null.
|
/// The [dispatcher] parameter must not be null.
|
||||||
PlatformViewTwoIntersectingOverlaysScenario(PlatformDispatcher dispatcher, String text, { this.id })
|
PlatformViewTwoIntersectingOverlaysScenario(PlatformDispatcher dispatcher, String text, { required this.id })
|
||||||
: assert(dispatcher != null),
|
: assert(dispatcher != null),
|
||||||
super(dispatcher) {
|
super(dispatcher) {
|
||||||
createPlatformView(dispatcher, text, id);
|
createPlatformView(dispatcher, text, id);
|
||||||
@@ -171,7 +170,7 @@ class PlatformViewOneOverlayTwoIntersectingOverlaysScenario extends Scenario wit
|
|||||||
/// Creates the PlatformView scenario.
|
/// Creates the PlatformView scenario.
|
||||||
///
|
///
|
||||||
/// The [dispatcher] parameter must not be null.
|
/// The [dispatcher] parameter must not be null.
|
||||||
PlatformViewOneOverlayTwoIntersectingOverlaysScenario(PlatformDispatcher dispatcher, String text, { this.id })
|
PlatformViewOneOverlayTwoIntersectingOverlaysScenario(PlatformDispatcher dispatcher, String text, { required this.id })
|
||||||
: assert(dispatcher != null),
|
: assert(dispatcher != null),
|
||||||
super(dispatcher) {
|
super(dispatcher) {
|
||||||
createPlatformView(dispatcher, text, id);
|
createPlatformView(dispatcher, text, id);
|
||||||
@@ -215,7 +214,7 @@ class MultiPlatformViewWithoutOverlaysScenario extends Scenario with _BasePlatfo
|
|||||||
/// Creates the PlatformView scenario.
|
/// Creates the PlatformView scenario.
|
||||||
///
|
///
|
||||||
/// The [dispatcher] parameter must not be null.
|
/// The [dispatcher] parameter must not be null.
|
||||||
MultiPlatformViewWithoutOverlaysScenario(PlatformDispatcher dispatcher, String text, { this.firstId, this.secondId })
|
MultiPlatformViewWithoutOverlaysScenario(PlatformDispatcher dispatcher, String text, { required this.firstId, required this.secondId })
|
||||||
: assert(dispatcher != null),
|
: assert(dispatcher != null),
|
||||||
super(dispatcher) {
|
super(dispatcher) {
|
||||||
createPlatformView(dispatcher, text, firstId);
|
createPlatformView(dispatcher, text, firstId);
|
||||||
@@ -259,7 +258,7 @@ class PlatformViewMaxOverlaysScenario extends Scenario with _BasePlatformViewSce
|
|||||||
/// Creates the PlatformView scenario.
|
/// Creates the PlatformView scenario.
|
||||||
///
|
///
|
||||||
/// The [dispatcher] parameter must not be null.
|
/// The [dispatcher] parameter must not be null.
|
||||||
PlatformViewMaxOverlaysScenario(PlatformDispatcher dispatcher, String text, { this.id })
|
PlatformViewMaxOverlaysScenario(PlatformDispatcher dispatcher, String text, { required this.id })
|
||||||
: assert(dispatcher != null),
|
: assert(dispatcher != null),
|
||||||
super(dispatcher) {
|
super(dispatcher) {
|
||||||
createPlatformView(dispatcher, text, id);
|
createPlatformView(dispatcher, text, id);
|
||||||
@@ -308,7 +307,7 @@ class MultiPlatformViewScenario extends Scenario with _BasePlatformViewScenarioM
|
|||||||
/// Creates the PlatformView scenario.
|
/// Creates the PlatformView scenario.
|
||||||
///
|
///
|
||||||
/// The [dispatcher] parameter must not be null.
|
/// The [dispatcher] parameter must not be null.
|
||||||
MultiPlatformViewScenario(PlatformDispatcher dispatcher, {this.firstId, this.secondId})
|
MultiPlatformViewScenario(PlatformDispatcher dispatcher, {required this.firstId, required this.secondId})
|
||||||
: assert(dispatcher != null),
|
: assert(dispatcher != null),
|
||||||
super(dispatcher) {
|
super(dispatcher) {
|
||||||
createPlatformView(dispatcher, 'platform view 1', firstId);
|
createPlatformView(dispatcher, 'platform view 1', firstId);
|
||||||
@@ -342,7 +341,7 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario with _BaseP
|
|||||||
/// Creates the PlatformView scenario.
|
/// Creates the PlatformView scenario.
|
||||||
///
|
///
|
||||||
/// The [dispatcher] parameter must not be null.
|
/// The [dispatcher] parameter must not be null.
|
||||||
MultiPlatformViewBackgroundForegroundScenario(PlatformDispatcher dispatcher, {this.firstId, this.secondId})
|
MultiPlatformViewBackgroundForegroundScenario(PlatformDispatcher dispatcher, {required this.firstId, required this.secondId})
|
||||||
: assert(dispatcher != null),
|
: assert(dispatcher != null),
|
||||||
super(dispatcher) {
|
super(dispatcher) {
|
||||||
_nextFrame = _firstFrame;
|
_nextFrame = _firstFrame;
|
||||||
@@ -361,7 +360,7 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario with _BaseP
|
|||||||
_nextFrame();
|
_nextFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
VoidCallback _nextFrame;
|
late VoidCallback _nextFrame;
|
||||||
|
|
||||||
void _firstFrame() {
|
void _firstFrame() {
|
||||||
final SceneBuilder builder = SceneBuilder();
|
final SceneBuilder builder = SceneBuilder();
|
||||||
@@ -407,13 +406,13 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario with _BaseP
|
|||||||
@override
|
@override
|
||||||
void onPlatformMessage(
|
void onPlatformMessage(
|
||||||
String name,
|
String name,
|
||||||
ByteData data,
|
ByteData? data,
|
||||||
PlatformMessageResponseCallback callback,
|
PlatformMessageResponseCallback? callback,
|
||||||
) {
|
) {
|
||||||
if (name != 'flutter/lifecycle') {
|
if (name != 'flutter/lifecycle') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final String message = utf8.decode(data.buffer.asUint8List());
|
final String message = utf8.decode(data!.buffer.asUint8List());
|
||||||
if (_lastLifecycleState == 'AppLifecycleState.inactive' && message == 'AppLifecycleState.resumed') {
|
if (_lastLifecycleState == 'AppLifecycleState.inactive' && message == 'AppLifecycleState.resumed') {
|
||||||
_nextFrame = _secondFrame;
|
_nextFrame = _secondFrame;
|
||||||
window.scheduleFrame();
|
window.scheduleFrame();
|
||||||
@@ -426,7 +425,7 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario with _BaseP
|
|||||||
/// Platform view with clip rect.
|
/// Platform view with clip rect.
|
||||||
class PlatformViewClipRectScenario extends Scenario with _BasePlatformViewScenarioMixin {
|
class PlatformViewClipRectScenario extends Scenario with _BasePlatformViewScenarioMixin {
|
||||||
/// Constructs a platform view with clip rect scenario.
|
/// Constructs a platform view with clip rect scenario.
|
||||||
PlatformViewClipRectScenario(PlatformDispatcher dispatcher, String text, { this.id })
|
PlatformViewClipRectScenario(PlatformDispatcher dispatcher, String text, { required this.id })
|
||||||
: assert(dispatcher != null),
|
: assert(dispatcher != null),
|
||||||
super(dispatcher) {
|
super(dispatcher) {
|
||||||
createPlatformView(dispatcher, text, id);
|
createPlatformView(dispatcher, text, id);
|
||||||
@@ -524,15 +523,10 @@ class PlatformViewOpacityScenario extends PlatformViewScenario {
|
|||||||
/// A simple platform view for testing touch events from iOS.
|
/// A simple platform view for testing touch events from iOS.
|
||||||
class PlatformViewForTouchIOSScenario extends Scenario
|
class PlatformViewForTouchIOSScenario extends Scenario
|
||||||
with _BasePlatformViewScenarioMixin {
|
with _BasePlatformViewScenarioMixin {
|
||||||
|
|
||||||
int _viewId;
|
|
||||||
bool _accept;
|
|
||||||
|
|
||||||
VoidCallback _nextFrame;
|
|
||||||
/// Creates the PlatformView scenario.
|
/// Creates the PlatformView scenario.
|
||||||
///
|
///
|
||||||
/// The [dispatcher] parameter must not be null.
|
/// The [dispatcher] parameter must not be null.
|
||||||
PlatformViewForTouchIOSScenario(PlatformDispatcher dispatcher, String text, {int id = 0, bool accept, bool rejectUntilTouchesEnded = false})
|
PlatformViewForTouchIOSScenario(PlatformDispatcher dispatcher, String text, {int id = 0, required bool accept, bool rejectUntilTouchesEnded = false})
|
||||||
: assert(dispatcher != null),
|
: assert(dispatcher != null),
|
||||||
_accept = accept,
|
_accept = accept,
|
||||||
_viewId = id,
|
_viewId = id,
|
||||||
@@ -545,6 +539,10 @@ class PlatformViewForTouchIOSScenario extends Scenario
|
|||||||
_nextFrame = _firstFrame;
|
_nextFrame = _firstFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _viewId;
|
||||||
|
bool _accept;
|
||||||
|
late VoidCallback _nextFrame;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onBeginFrame(Duration duration) {
|
void onBeginFrame(Duration duration) {
|
||||||
_nextFrame();
|
_nextFrame();
|
||||||
@@ -587,7 +585,7 @@ class PlatformViewForTouchIOSScenario extends Scenario
|
|||||||
window.sendPlatformMessage(
|
window.sendPlatformMessage(
|
||||||
'flutter/platform_views',
|
'flutter/platform_views',
|
||||||
message.buffer.asByteData(),
|
message.buffer.asByteData(),
|
||||||
(ByteData response) {},
|
(ByteData? response) {},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -622,10 +620,10 @@ class PlatformViewWithContinuousTexture extends PlatformViewScenario {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mixin _BasePlatformViewScenarioMixin on Scenario {
|
mixin _BasePlatformViewScenarioMixin on Scenario {
|
||||||
int _textureId;
|
int? _textureId;
|
||||||
|
|
||||||
bool get usesAndroidHybridComposition {
|
bool get usesAndroidHybridComposition {
|
||||||
return (scenarioParams['use_android_view'] as bool) == true;
|
return (scenarioParams['use_android_view'] as bool?) == true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct the platform view related scenario
|
/// Construct the platform view related scenario
|
||||||
@@ -702,7 +700,7 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
|
|||||||
dispatcher.sendPlatformMessage(
|
dispatcher.sendPlatformMessage(
|
||||||
'flutter/platform_views',
|
'flutter/platform_views',
|
||||||
message.buffer.asByteData(),
|
message.buffer.asByteData(),
|
||||||
(ByteData response) {
|
(ByteData? response) {
|
||||||
if (response != null && Platform.isAndroid && !usesAndroidHybridComposition) {
|
if (response != null && Platform.isAndroid && !usesAndroidHybridComposition) {
|
||||||
// Envelope.
|
// Envelope.
|
||||||
_textureId = response.getUint8(0);
|
_textureId = response.getUint8(0);
|
||||||
@@ -723,7 +721,7 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
|
|||||||
if (usesAndroidHybridComposition) {
|
if (usesAndroidHybridComposition) {
|
||||||
sceneBuilder.addPlatformView(viewId, width: width, height: height);
|
sceneBuilder.addPlatformView(viewId, width: width, height: height);
|
||||||
} else if (_textureId != null) {
|
} else if (_textureId != null) {
|
||||||
sceneBuilder.addTexture(_textureId, width: width, height: height);
|
sceneBuilder.addTexture(_textureId!, width: width, height: height);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw UnsupportedError('Platform ${Platform.operatingSystem} is not supported');
|
throw UnsupportedError('Platform ${Platform.operatingSystem} is not supported');
|
||||||
@@ -734,7 +732,7 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
|
|||||||
void finishBuilderByAddingPlatformViewAndPicture(
|
void finishBuilderByAddingPlatformViewAndPicture(
|
||||||
SceneBuilder sceneBuilder,
|
SceneBuilder sceneBuilder,
|
||||||
int viewId, {
|
int viewId, {
|
||||||
Offset overlayOffset,
|
Offset? overlayOffset,
|
||||||
}) {
|
}) {
|
||||||
overlayOffset ??= const Offset(50, 50);
|
overlayOffset ??= const Offset(50, 50);
|
||||||
_addPlatformViewToScene(
|
_addPlatformViewToScene(
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.6
|
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:scenario_app/src/channel_util.dart';
|
import 'package:scenario_app/src/channel_util.dart';
|
||||||
@@ -20,7 +19,7 @@ class PoppableScreenScenario extends Scenario with PlatformEchoMixin {
|
|||||||
super(dispatcher);
|
super(dispatcher);
|
||||||
|
|
||||||
// Rect for the pop button. Only defined once onMetricsChanged is called.
|
// Rect for the pop button. Only defined once onMetricsChanged is called.
|
||||||
Rect _buttonRect;
|
Rect? _buttonRect;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onBeginFrame(Duration duration) {
|
void onBeginFrame(Duration duration) {
|
||||||
@@ -32,7 +31,7 @@ class PoppableScreenScenario extends Scenario with PlatformEchoMixin {
|
|||||||
|
|
||||||
if (_buttonRect != null) {
|
if (_buttonRect != null) {
|
||||||
canvas.drawRect(
|
canvas.drawRect(
|
||||||
_buttonRect,
|
_buttonRect!,
|
||||||
Paint()..color = const Color.fromARGB(255, 255, 0, 0),
|
Paint()..color = const Color.fromARGB(255, 255, 0, 0),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.6
|
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
@@ -59,7 +58,7 @@ abstract class Scenario {
|
|||||||
/// See [PlatformDispatcher.onPlatformMessage].
|
/// See [PlatformDispatcher.onPlatformMessage].
|
||||||
void onPlatformMessage(
|
void onPlatformMessage(
|
||||||
String name,
|
String name,
|
||||||
ByteData data,
|
ByteData? data,
|
||||||
PlatformMessageResponseCallback callback,
|
PlatformMessageResponseCallback? callback,
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.6
|
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'animated_color_square.dart';
|
import 'animated_color_square.dart';
|
||||||
@@ -53,7 +52,7 @@ Map<String, ScenarioFactory> _scenarios = <String, ScenarioFactory>{
|
|||||||
|
|
||||||
Map<String, dynamic> _currentScenarioParams = <String, dynamic>{};
|
Map<String, dynamic> _currentScenarioParams = <String, dynamic>{};
|
||||||
|
|
||||||
Scenario _currentScenarioInstance;
|
Scenario? _currentScenarioInstance;
|
||||||
|
|
||||||
/// Loads an scenario.
|
/// Loads an scenario.
|
||||||
/// The map must contain a `name` entry, which equals to the name of the scenario.
|
/// The map must contain a `name` entry, which equals to the name of the scenario.
|
||||||
@@ -63,16 +62,16 @@ void loadScenario(Map<String, dynamic> scenario) {
|
|||||||
_currentScenarioParams = scenario;
|
_currentScenarioParams = scenario;
|
||||||
|
|
||||||
if (_currentScenarioInstance != null) {
|
if (_currentScenarioInstance != null) {
|
||||||
_currentScenarioInstance.unmount();
|
_currentScenarioInstance!.unmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentScenarioInstance = _scenarios[scenario['name']]();
|
_currentScenarioInstance = _scenarios[scenario['name']]!();
|
||||||
window.scheduleFrame();
|
window.scheduleFrame();
|
||||||
print('Loading scenario $scenarioName');
|
print('Loading scenario $scenarioName');
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the loaded [Scenario].
|
/// Gets the loaded [Scenario].
|
||||||
Scenario get currentScenario {
|
Scenario? get currentScenario {
|
||||||
return _currentScenarioInstance;
|
return _currentScenarioInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.6
|
|
||||||
|
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.6
|
|
||||||
|
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'channel_util.dart';
|
import 'channel_util.dart';
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
name: scenario_app
|
name: scenario_app
|
||||||
publish_to: none
|
publish_to: none
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.12.0-0 <3.0.0'
|
sdk: '>=2.12.0 <3.0.0'
|
||||||
|
|
||||||
# Do not add any dependencies that require more than what is provided in
|
# Do not add any dependencies that require more than what is provided in
|
||||||
# //third_party/dart/pkg, //third_party/dart/third_party/pkg, or
|
# //third_party/dart/pkg, //third_party/dart/third_party/pkg, or
|
||||||
@@ -19,8 +19,6 @@ dependencies:
|
|||||||
vector_math: any
|
vector_math: any
|
||||||
|
|
||||||
dependency_overrides:
|
dependency_overrides:
|
||||||
meta:
|
|
||||||
path: ../../../third_party/dart/pkg/meta
|
|
||||||
sky_engine:
|
sky_engine:
|
||||||
path: ../../sky/packages/sky_engine
|
path: ../../sky/packages/sky_engine
|
||||||
vector_math:
|
vector_math:
|
||||||
|
|||||||
Reference in New Issue
Block a user