Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/dart/rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ template("dart_snapshot") {
"--depfile=$abs_depfile",
"--depfile_output_filename=$rebased_output",
"--disable-dart-dev",
"--sound-null-safety",
]

args = [
Expand Down
12 changes: 6 additions & 6 deletions testing/scenario_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.6

import 'dart:convert';
import 'dart:developer' as developer;
import 'dart:io';
Expand All @@ -27,7 +27,7 @@ void main() {
}

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

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

switch (name) {
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;
case 'write_timeline':
final String timelineData = await _getTimelineData();
callback(Uint8List.fromList(utf8.encode(timelineData)).buffer.asByteData());
callback!(Uint8List.fromList(utf8.encode(timelineData)).buffer.asByteData());
break;
default:
currentScenario?.onPlatformMessage(name, data, callback);
Expand All @@ -61,7 +61,7 @@ Future<void> _handlePlatformMessage(

Future<String> _getTimelineData() async {
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> vmServiceResult = vmServiceTimelineJson['result'] as Map<String, dynamic>;
return json.encode(<String, dynamic>{
Expand Down
3 changes: 1 addition & 2 deletions testing/scenario_app/lib/src/animated_color_square.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.6
import 'dart:math' as math;
import 'dart:ui';

Expand Down Expand Up @@ -89,7 +88,7 @@ class _NumberSwinger<T extends num> {

/// The current value of the swinger.
T get current => _current;
T _current;
late T _current;

bool _up;

Expand Down
1 change: 0 additions & 1 deletion testing/scenario_app/lib/src/bogus_font_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.6
import 'dart:ui';

import 'channel_util.dart';
Expand Down
18 changes: 8 additions & 10 deletions testing/scenario_app/lib/src/channel_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.6

import 'dart:convert';
import 'dart:ui';

Expand All @@ -12,11 +10,11 @@ import 'package:meta/meta.dart';
/// Util method to replicate the behavior of a `MethodChannel` in the Flutter
/// framework.
void sendJsonMethodCall({
@required PlatformDispatcher dispatcher,
@required String channel,
@required String method,
required PlatformDispatcher dispatcher,
required String channel,
required String method,
dynamic arguments,
PlatformMessageResponseCallback callback,
PlatformMessageResponseCallback? callback,
}) {
sendJsonMessage(
dispatcher: dispatcher,
Expand All @@ -30,10 +28,10 @@ void sendJsonMethodCall({

/// Send a JSON message over a channel.
void sendJsonMessage({
@required PlatformDispatcher dispatcher,
@required String channel,
@required Map<String, dynamic> json,
PlatformMessageResponseCallback callback,
required PlatformDispatcher dispatcher,
required String channel,
required Map<String, dynamic> json,
PlatformMessageResponseCallback? callback,
}) {
dispatcher.sendPlatformMessage(
channel,
Expand Down
1 change: 0 additions & 1 deletion testing/scenario_app/lib/src/initial_route_reply.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.6
import 'dart:ui';

import 'channel_util.dart';
Expand Down
2 changes: 0 additions & 2 deletions testing/scenario_app/lib/src/locale_initialization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.6

import 'dart:typed_data';
import 'dart:ui';

Expand Down
5 changes: 2 additions & 3 deletions testing/scenario_app/lib/src/platform_echo_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.6
import 'dart:typed_data';
import 'dart:ui';

Expand All @@ -13,8 +12,8 @@ mixin PlatformEchoMixin on Scenario {
@override
void onPlatformMessage(
String name,
ByteData data,
PlatformMessageResponseCallback callback,
ByteData? data,
PlatformMessageResponseCallback? callback,
) {
window.sendPlatformMessage(name, data, null);
}
Expand Down
54 changes: 26 additions & 28 deletions testing/scenario_app/lib/src/platform_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.6
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';
Expand Down Expand Up @@ -33,7 +32,7 @@ class PlatformViewScenario extends Scenario with _BasePlatformViewScenarioMixin
/// Creates the PlatformView scenario.
///
/// 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),
super(dispatcher) {
createPlatformView(dispatcher, text, id);
Expand All @@ -58,7 +57,7 @@ class NonFullScreenFlutterViewPlatformViewScenario extends Scenario
/// The [dispatcher] parameter must not be null.
NonFullScreenFlutterViewPlatformViewScenario(
PlatformDispatcher dispatcher, String text,
{this.id})
{required this.id})
: assert(dispatcher != null),
super(dispatcher) {
createPlatformView(dispatcher, text, id);
Expand All @@ -80,7 +79,7 @@ class PlatformViewNoOverlayIntersectionScenario extends Scenario with _BasePlatf
/// Creates the PlatformView scenario.
///
/// 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),
super(dispatcher) {
createPlatformView(dispatcher, text, id);
Expand All @@ -106,7 +105,7 @@ class PlatformViewPartialIntersectionScenario extends Scenario with _BasePlatfor
/// Creates the PlatformView scenario.
///
/// 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),
super(dispatcher) {
createPlatformView(dispatcher, text, id);
Expand All @@ -132,7 +131,7 @@ class PlatformViewTwoIntersectingOverlaysScenario extends Scenario with _BasePla
/// Creates the PlatformView scenario.
///
/// 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),
super(dispatcher) {
createPlatformView(dispatcher, text, id);
Expand Down Expand Up @@ -171,7 +170,7 @@ class PlatformViewOneOverlayTwoIntersectingOverlaysScenario extends Scenario wit
/// Creates the PlatformView scenario.
///
/// 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),
super(dispatcher) {
createPlatformView(dispatcher, text, id);
Expand Down Expand Up @@ -215,7 +214,7 @@ class MultiPlatformViewWithoutOverlaysScenario extends Scenario with _BasePlatfo
/// Creates the PlatformView scenario.
///
/// 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),
super(dispatcher) {
createPlatformView(dispatcher, text, firstId);
Expand Down Expand Up @@ -259,7 +258,7 @@ class PlatformViewMaxOverlaysScenario extends Scenario with _BasePlatformViewSce
/// Creates the PlatformView scenario.
///
/// 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),
super(dispatcher) {
createPlatformView(dispatcher, text, id);
Expand Down Expand Up @@ -308,7 +307,7 @@ class MultiPlatformViewScenario extends Scenario with _BasePlatformViewScenarioM
/// Creates the PlatformView scenario.
///
/// 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),
super(dispatcher) {
createPlatformView(dispatcher, 'platform view 1', firstId);
Expand Down Expand Up @@ -342,7 +341,7 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario with _BaseP
/// Creates the PlatformView scenario.
///
/// 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),
super(dispatcher) {
_nextFrame = _firstFrame;
Expand All @@ -361,7 +360,7 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario with _BaseP
_nextFrame();
}

VoidCallback _nextFrame;
late VoidCallback _nextFrame;

void _firstFrame() {
final SceneBuilder builder = SceneBuilder();
Expand Down Expand Up @@ -407,13 +406,13 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario with _BaseP
@override
void onPlatformMessage(
String name,
ByteData data,
PlatformMessageResponseCallback callback,
ByteData? data,
PlatformMessageResponseCallback? callback,
) {
if (name != 'flutter/lifecycle') {
return;
}
final String message = utf8.decode(data.buffer.asUint8List());
final String message = utf8.decode(data!.buffer.asUint8List());
if (_lastLifecycleState == 'AppLifecycleState.inactive' && message == 'AppLifecycleState.resumed') {
_nextFrame = _secondFrame;
window.scheduleFrame();
Expand All @@ -426,7 +425,7 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario with _BaseP
/// Platform view with clip rect.
class PlatformViewClipRectScenario extends Scenario with _BasePlatformViewScenarioMixin {
/// 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),
super(dispatcher) {
createPlatformView(dispatcher, text, id);
Expand Down Expand Up @@ -524,15 +523,10 @@ class PlatformViewOpacityScenario extends PlatformViewScenario {
/// A simple platform view for testing touch events from iOS.
class PlatformViewForTouchIOSScenario extends Scenario
with _BasePlatformViewScenarioMixin {

int _viewId;
bool _accept;

VoidCallback _nextFrame;
/// Creates the PlatformView scenario.
///
/// 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),
_accept = accept,
_viewId = id,
Expand All @@ -545,6 +539,10 @@ class PlatformViewForTouchIOSScenario extends Scenario
_nextFrame = _firstFrame;
}

int _viewId;
bool _accept;
late VoidCallback _nextFrame;

@override
void onBeginFrame(Duration duration) {
_nextFrame();
Expand Down Expand Up @@ -587,7 +585,7 @@ class PlatformViewForTouchIOSScenario extends Scenario
window.sendPlatformMessage(
'flutter/platform_views',
message.buffer.asByteData(),
(ByteData response) {},
(ByteData? response) {},
);
}

Expand Down Expand Up @@ -622,10 +620,10 @@ class PlatformViewWithContinuousTexture extends PlatformViewScenario {
}

mixin _BasePlatformViewScenarioMixin on Scenario {
int _textureId;
int? _textureId;

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
Expand Down Expand Up @@ -702,7 +700,7 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
dispatcher.sendPlatformMessage(
'flutter/platform_views',
message.buffer.asByteData(),
(ByteData response) {
(ByteData? response) {
if (response != null && Platform.isAndroid && !usesAndroidHybridComposition) {
// Envelope.
_textureId = response.getUint8(0);
Expand All @@ -723,7 +721,7 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
if (usesAndroidHybridComposition) {
sceneBuilder.addPlatformView(viewId, width: width, height: height);
} else if (_textureId != null) {
sceneBuilder.addTexture(_textureId, width: width, height: height);
sceneBuilder.addTexture(_textureId!, width: width, height: height);
}
} else {
throw UnsupportedError('Platform ${Platform.operatingSystem} is not supported');
Expand All @@ -734,7 +732,7 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
void finishBuilderByAddingPlatformViewAndPicture(
SceneBuilder sceneBuilder,
int viewId, {
Offset overlayOffset,
Offset? overlayOffset,
}) {
overlayOffset ??= const Offset(50, 50);
_addPlatformViewToScene(
Expand Down
5 changes: 2 additions & 3 deletions testing/scenario_app/lib/src/poppable_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.6
import 'dart:ui';

import 'package:scenario_app/src/channel_util.dart';
Expand All @@ -20,7 +19,7 @@ class PoppableScreenScenario extends Scenario with PlatformEchoMixin {
super(dispatcher);

// Rect for the pop button. Only defined once onMetricsChanged is called.
Rect _buttonRect;
Rect? _buttonRect;

@override
void onBeginFrame(Duration duration) {
Expand All @@ -32,7 +31,7 @@ class PoppableScreenScenario extends Scenario with PlatformEchoMixin {

if (_buttonRect != null) {
canvas.drawRect(
_buttonRect,
_buttonRect!,
Paint()..color = const Color.fromARGB(255, 255, 0, 0),
);
}
Expand Down
Loading