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