Unverified Commit f55b2665 authored by Abhishek Ghaskata's avatar Abhishek Ghaskata Committed by GitHub

Migrate channels to null safety (#80641)

parent 4f2e7987
......@@ -19,7 +19,7 @@ void main() {
}
class TestApp extends StatefulWidget {
const TestApp({Key key}) : super(key: key);
const TestApp({Key? key}) : super(key: key);
@override
_TestAppState createState() => _TestAppState();
......@@ -155,7 +155,7 @@ class _TestAppState extends State<TestApp> {
() => basicJsonMessageToUnknownChannel(),
() => basicStandardMessageToUnknownChannel(),
];
Future<TestStepResult> _result;
Future<TestStepResult>? _result;
int _step = 0;
void _executeNextStep() {
......
......@@ -42,25 +42,25 @@ class ExtendedStandardMessageCodec extends StandardMessageCodec {
}
}
Future<TestStepResult> basicBinaryHandshake(ByteData message) async {
Future<TestStepResult> basicBinaryHandshake(ByteData? message) async {
const BasicMessageChannel<ByteData> channel =
BasicMessageChannel<ByteData>(
'binary-msg',
BinaryCodec(),
);
return _basicMessageHandshake<ByteData>(
return _basicMessageHandshake<ByteData?>(
'Binary >${toString(message)}<', channel, message);
}
Future<TestStepResult> basicStringHandshake(String message) async {
Future<TestStepResult> basicStringHandshake(String? message) async {
const BasicMessageChannel<String> channel = BasicMessageChannel<String>(
'string-msg',
StringCodec(),
);
return _basicMessageHandshake<String>('String >$message<', channel, message);
return _basicMessageHandshake<String?>('String >$message<', channel, message);
}
Future<TestStepResult> basicJsonHandshake(dynamic message) async {
Future<TestStepResult> basicJsonHandshake(Object? message) async {
const BasicMessageChannel<dynamic> channel =
BasicMessageChannel<dynamic>(
'json-msg',
......@@ -126,9 +126,9 @@ Future<TestStepResult> _basicMessageHandshake<T>(
T message,
) async {
final List<dynamic> received = <dynamic>[];
channel.setMessageHandler((T message) async {
channel.setMessageHandler((T? message) async {
received.add(message);
return message;
return message!;
});
dynamic messageEcho = nothing;
dynamic error = nothing;
......@@ -150,7 +150,7 @@ Future<TestStepResult> _basicMessageHandshake<T>(
/// Sends a message on a channel that no one listens on.
Future<TestStepResult> _basicMessageToUnknownChannel<T>(
String description,
BasicMessageChannel<T> channel,
BasicMessageChannel<T?> channel,
) async {
dynamic messageEcho = nothing;
dynamic error = nothing;
......
......@@ -44,12 +44,11 @@ class TestStepResult {
return const TestStepResult('Executing', nothing, TestStatus.pending);
case ConnectionState.done:
if (snapshot.hasData) {
return snapshot.data;
return snapshot.data!;
} else {
final TestStepResult result = snapshot.error as TestStepResult;
final TestStepResult result = snapshot.error! as TestStepResult;
return result;
}
break;
default:
throw 'Unsupported state ${snapshot.connectionState}';
}
......
......@@ -2,7 +2,7 @@ name: channels
description: Integration test for platform channels.
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
......
......@@ -7,7 +7,7 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
void main() {
group('channel suite', () {
FlutterDriver driver;
late FlutterDriver driver;
setUpAll(() async {
driver = await FlutterDriver.connect();
......@@ -28,7 +28,7 @@ void main() {
}, timeout: const Timeout(Duration(minutes: 1)));
tearDownAll(() async {
driver?.close();
driver.close();
});
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment