Unverified Commit 58287ace authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Convert services tests to NNBD (#62694)

This converts the packages/flutter/test/services directory to NNBD, now that the services package is converted.

I changed the signature of checkMessageHandler and checkMockMessageHandler on BinaryMessenger to take a nullable handler, since the tests wanted to check to make sure a handler wasn't set, and that functionality no longer works if the handler is non-nullable.
parent ddab09f5
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
# 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.
set -e
# The tests to run on Firebase Test Lab. # The tests to run on Firebase Test Lab.
# Currently, the test consists on building an Android App Bundle and ensuring # Currently, the test consists on building an Android App Bundle and ensuring
# that the app doesn't crash upon startup. # that the app doesn't crash upon startup.
...@@ -26,8 +28,6 @@ devices=( ...@@ -26,8 +28,6 @@ devices=(
"model=griffin,version=24" "model=griffin,version=24"
) )
set -e
GIT_REVISION=$(git rev-parse HEAD) GIT_REVISION=$(git rev-parse HEAD)
DEVICE_FLAG="" DEVICE_FLAG=""
...@@ -35,6 +35,12 @@ for device in ${devices[*]}; do ...@@ -35,6 +35,12 @@ for device in ${devices[*]}; do
DEVICE_FLAG+="--device $device " DEVICE_FLAG+="--device $device "
done done
# If running tests locally, the key env var needs to be set.
if [[ -z $GCLOUD_FIREBASE_TESTLAB_KEY ]]; then
echo "Not running firebase test lab tests because GCLOUD_FIREBASE_TESTLAB_KEY isn't set."
exit 0
fi
# New contributors will not have permissions to run this test - they won't be # New contributors will not have permissions to run this test - they won't be
# able to access the service account information. We should just mark the test # able to access the service account information. We should just mark the test
# as passed - it will run fine on post submit, where it will still catch # as passed - it will run fine on post submit, where it will still catch
......
...@@ -48,6 +48,9 @@ abstract class BinaryMessenger { ...@@ -48,6 +48,9 @@ abstract class BinaryMessenger {
/// ///
/// This method is useful for tests or test harnesses that want to assert the /// This method is useful for tests or test harnesses that want to assert the
/// handler for the specified channel has not been altered by a previous test. /// handler for the specified channel has not been altered by a previous test.
///
/// Passing null for the `handler` returns true if the handler for the
/// `channel` is not set.
bool checkMessageHandler(String channel, MessageHandler? handler); bool checkMessageHandler(String channel, MessageHandler? handler);
/// Set a mock callback for intercepting messages from the [send] method on /// Set a mock callback for intercepting messages from the [send] method on
...@@ -69,6 +72,9 @@ abstract class BinaryMessenger { ...@@ -69,6 +72,9 @@ abstract class BinaryMessenger {
/// This method is useful for tests or test harnesses that want to assert the /// This method is useful for tests or test harnesses that want to assert the
/// mock handler for the specified channel has not been altered by a previous /// mock handler for the specified channel has not been altered by a previous
/// test. /// test.
///
/// Passing null for the `handler` returns true if the handler for the
/// `channel` is not set.
bool checkMockMessageHandler(String channel, MessageHandler? handler); bool checkMockMessageHandler(String channel, MessageHandler? handler);
} }
......
...@@ -389,6 +389,9 @@ class MethodChannel { ...@@ -389,6 +389,9 @@ class MethodChannel {
/// ///
/// This method is useful for tests or test harnesses that want to assert the /// This method is useful for tests or test harnesses that want to assert the
/// handler for the specified channel has not been altered by a previous test. /// handler for the specified channel has not been altered by a previous test.
///
/// Passing null for the `handler` returns true if the handler for the channel
/// is not set.
bool checkMethodCallHandler(Future<dynamic> Function(MethodCall call)? handler) => _methodChannelHandlers[this] == handler; bool checkMethodCallHandler(Future<dynamic> Function(MethodCall call)? handler) => _methodChannelHandlers[this] == handler;
/// Sets a mock callback for intercepting method invocations on this channel. /// Sets a mock callback for intercepting method invocations on this channel.
...@@ -422,6 +425,9 @@ class MethodChannel { ...@@ -422,6 +425,9 @@ class MethodChannel {
/// ///
/// This method is useful for tests or test harnesses that want to assert the /// This method is useful for tests or test harnesses that want to assert the
/// handler for the specified channel has not been altered by a previous test. /// handler for the specified channel has not been altered by a previous test.
///
/// Passing null for the `handler` returns true if the handler for the channel
/// is not set.
bool checkMockMethodCallHandler(Future<dynamic> Function(MethodCall call)? handler) => _methodChannelMockHandlers[this] == handler; bool checkMockMethodCallHandler(Future<dynamic> Function(MethodCall call)? handler) => _methodChannelMockHandlers[this] == handler;
Future<ByteData?> _handleAsMethodCall(ByteData? message, Future<dynamic> handler(MethodCall call)) async { Future<ByteData?> _handleAsMethodCall(ByteData? message, Future<dynamic> handler(MethodCall call)) async {
......
...@@ -2,8 +2,6 @@ ...@@ -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.8
import 'dart:convert'; import 'dart:convert';
import 'dart:typed_data'; import 'dart:typed_data';
...@@ -41,7 +39,7 @@ void main() { ...@@ -41,7 +39,7 @@ void main() {
expect(bundle.loadCallCount['one'], 1); expect(bundle.loadCallCount['one'], 1);
Object loadException; late Object loadException;
try { try {
await bundle.loadString('foo'); await bundle.loadString('foo');
} catch (e) { } catch (e) {
...@@ -61,7 +59,7 @@ void main() { ...@@ -61,7 +59,7 @@ void main() {
test('NetworkAssetBundle control test', () async { test('NetworkAssetBundle control test', () async {
final Uri uri = Uri.http('example.org', '/path'); final Uri uri = Uri.http('example.org', '/path');
final NetworkAssetBundle bundle = NetworkAssetBundle(uri); final NetworkAssetBundle bundle = NetworkAssetBundle(uri);
FlutterError error; late FlutterError error;
try { try {
await bundle.load('key'); await bundle.load('key');
} on FlutterError catch (e) { } on FlutterError catch (e) {
......
...@@ -2,8 +2,6 @@ ...@@ -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.8
import 'dart:convert' show utf8; import 'dart:convert' show utf8;
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
...@@ -13,13 +11,12 @@ void main() { ...@@ -13,13 +11,12 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
group('TextInput message channels', () { group('TextInput message channels', () {
FakeTextChannel fakeTextChannel; late FakeTextChannel fakeTextChannel;
FakeAutofillScope scope; final FakeAutofillScope scope = FakeAutofillScope();
setUp(() { setUp(() {
fakeTextChannel = FakeTextChannel((MethodCall call) async {}); fakeTextChannel = FakeTextChannel((MethodCall call) async {});
TextInput.setChannel(fakeTextChannel); TextInput.setChannel(fakeTextChannel);
scope ??= FakeAutofillScope();
scope.clients.clear(); scope.clients.clear();
}); });
...@@ -28,35 +25,8 @@ void main() { ...@@ -28,35 +25,8 @@ void main() {
TextInput.setChannel(SystemChannels.textInput); TextInput.setChannel(SystemChannels.textInput);
}); });
test('mandatory fields are mandatory', () async {
AutofillConfiguration config;
try {
config = AutofillConfiguration(
uniqueIdentifier: null,
autofillHints: const <String>['test'],
currentEditingValue: const TextEditingValue(),
);
} catch (e) {
expect(e.toString(), contains('uniqueIdentifier != null'));
}
expect(config, isNull);
try {
config = AutofillConfiguration(
uniqueIdentifier: 'id',
autofillHints: null,
currentEditingValue: const TextEditingValue(),
);
} catch (e) {
expect(e.toString(), contains('autofillHints != null'));
}
expect(config, isNull);
});
test('throws if the hint list is empty', () async { test('throws if the hint list is empty', () async {
Map<String, dynamic> json; Map<String, dynamic>? json;
try { try {
const AutofillConfiguration config = AutofillConfiguration( const AutofillConfiguration config = AutofillConfiguration(
uniqueIdentifier: 'id', uniqueIdentifier: 'id',
...@@ -113,7 +83,7 @@ void main() { ...@@ -113,7 +83,7 @@ void main() {
]); ]);
const TextEditingValue text2 = TextEditingValue(text: 'Text 2'); const TextEditingValue text2 = TextEditingValue(text: 'Text 2');
fakeTextChannel.incoming(MethodCall( fakeTextChannel.incoming?.call(MethodCall(
'TextInputClient.updateEditingStateWithTag', 'TextInputClient.updateEditingStateWithTag',
<dynamic>[0, <String, dynamic>{ client2.autofillId : text2.toJSON() }], <dynamic>[0, <String, dynamic>{ client2.autofillId : text2.toJSON() }],
)); ));
...@@ -130,7 +100,7 @@ class FakeAutofillClient implements TextInputClient, AutofillClient { ...@@ -130,7 +100,7 @@ class FakeAutofillClient implements TextInputClient, AutofillClient {
String get autofillId => hashCode.toString(); String get autofillId => hashCode.toString();
@override @override
TextInputConfiguration textInputConfiguration; late TextInputConfiguration textInputConfiguration;
@override @override
void updateEditingValue(TextEditingValue newEditingValue) { void updateEditingValue(TextEditingValue newEditingValue) {
...@@ -139,7 +109,7 @@ class FakeAutofillClient implements TextInputClient, AutofillClient { ...@@ -139,7 +109,7 @@ class FakeAutofillClient implements TextInputClient, AutofillClient {
} }
@override @override
AutofillScope currentAutofillScope; AutofillScope? currentAutofillScope;
String latestMethodCall = ''; String latestMethodCall = '';
...@@ -179,7 +149,7 @@ class FakeAutofillScope with AutofillScopeMixin implements AutofillScope { ...@@ -179,7 +149,7 @@ class FakeAutofillScope with AutofillScopeMixin implements AutofillScope {
Iterable<AutofillClient> get autofillClients => clients.values; Iterable<AutofillClient> get autofillClients => clients.values;
@override @override
AutofillClient getAutofillClient(String autofillId) => clients[autofillId]; AutofillClient getAutofillClient(String autofillId) => clients[autofillId]!;
void register(AutofillClient client) { void register(AutofillClient client) {
clients.putIfAbsent(client.autofillId, () => client); clients.putIfAbsent(client.autofillId, () => client);
...@@ -190,7 +160,7 @@ class FakeTextChannel implements MethodChannel { ...@@ -190,7 +160,7 @@ class FakeTextChannel implements MethodChannel {
FakeTextChannel(this.outgoing) : assert(outgoing != null); FakeTextChannel(this.outgoing) : assert(outgoing != null);
Future<dynamic> Function(MethodCall) outgoing; Future<dynamic> Function(MethodCall) outgoing;
Future<void> Function(MethodCall) incoming; Future<void> Function(MethodCall)? incoming;
List<MethodCall> outgoingCalls = <MethodCall>[]; List<MethodCall> outgoingCalls = <MethodCall>[];
...@@ -217,18 +187,18 @@ class FakeTextChannel implements MethodChannel { ...@@ -217,18 +187,18 @@ class FakeTextChannel implements MethodChannel {
String get name => 'flutter/textinput'; String get name => 'flutter/textinput';
@override @override
void setMethodCallHandler(Future<void> Function(MethodCall call) handler) { void setMethodCallHandler(Future<void> Function(MethodCall call)? handler) {
incoming = handler; incoming = handler;
} }
@override @override
bool checkMethodCallHandler(Future<void> Function(MethodCall call) handler) => throw UnimplementedError(); bool checkMethodCallHandler(Future<void> Function(MethodCall call)? handler) => throw UnimplementedError();
@override @override
void setMockMethodCallHandler(Future<void> Function(MethodCall call) handler) => throw UnimplementedError(); void setMockMethodCallHandler(Future<void> Function(MethodCall call)? handler) => throw UnimplementedError();
@override @override
bool checkMockMethodCallHandler(Future<void> Function(MethodCall call) handler) => throw UnimplementedError(); bool checkMockMethodCallHandler(Future<void> Function(MethodCall call)? handler) => throw UnimplementedError();
void validateOutgoingMethodCalls(List<MethodCall> calls) { void validateOutgoingMethodCalls(List<MethodCall> calls) {
expect(outgoingCalls.length, calls.length); expect(outgoingCalls.length, calls.length);
......
...@@ -2,8 +2,6 @@ ...@@ -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.8
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -45,7 +43,7 @@ class TestBinding extends BindingBase with SchedulerBinding, ServicesBinding { ...@@ -45,7 +43,7 @@ class TestBinding extends BindingBase with SchedulerBinding, ServicesBinding {
@override @override
BinaryMessenger createBinaryMessenger() { BinaryMessenger createBinaryMessenger() {
return super.createBinaryMessenger() return super.createBinaryMessenger()
..setMockMessageHandler('flutter/assets', (ByteData message) async { ..setMockMessageHandler('flutter/assets', (ByteData? message) async {
if (const StringCodec().decodeMessage(message) == 'NOTICES') { if (const StringCodec().decodeMessage(message) == 'NOTICES') {
return const StringCodec().encodeMessage(licenses); return const StringCodec().encodeMessage(licenses);
} }
......
...@@ -2,8 +2,6 @@ ...@@ -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.8
// TODO(yjbanov): enable Web when https://github.com/flutter/engine/pull/12747 rolls into the framework. // TODO(yjbanov): enable Web when https://github.com/flutter/engine/pull/12747 rolls into the framework.
@TestOn('!chrome') @TestOn('!chrome')
...@@ -35,15 +33,15 @@ void main() { ...@@ -35,15 +33,15 @@ void main() {
final TestChannelBuffersFlutterBinding binding = TestChannelBuffersFlutterBinding(); final TestChannelBuffersFlutterBinding binding = TestChannelBuffersFlutterBinding();
expect(binding.defaultBinaryMessenger, isNotNull); expect(binding.defaultBinaryMessenger, isNotNull);
bool didCallCallback = false; bool didCallCallback = false;
final ui.PlatformMessageResponseCallback callback = (ByteData responseData) { final ui.PlatformMessageResponseCallback callback = (ByteData? responseData) {
didCallCallback = true; didCallCallback = true;
}; };
const String payload = 'bar'; const String payload = 'bar';
final ByteData data = _makeByteData(payload); final ByteData data = _makeByteData(payload);
ui.channelBuffers.push(channel, data, callback); ui.channelBuffers.push(channel, data, callback);
bool didDrainData = false; bool didDrainData = false;
binding.defaultBinaryMessenger.setMessageHandler(channel, (ByteData message) async { binding.defaultBinaryMessenger.setMessageHandler(channel, (ByteData? message) async {
expect(_getString(message), payload); expect(_getString(message!), payload);
didDrainData = true; didDrainData = true;
return null; return null;
}); });
......
...@@ -2,8 +2,6 @@ ...@@ -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.8
import 'dart:convert'; import 'dart:convert';
import 'dart:typed_data'; import 'dart:typed_data';
import 'dart:ui' as ui; import 'dart:ui' as ui;
...@@ -23,22 +21,21 @@ void main() { ...@@ -23,22 +21,21 @@ void main() {
test('default binary messenger calls callback once', () async { test('default binary messenger calls callback once', () async {
int count = 0; int count = 0;
const String channel = 'foo'; const String channel = 'foo';
ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage( ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage(
channel, _makeByteData('bar'), (ByteData message) async { channel, _makeByteData('bar'), (ByteData? message) async {
count += 1; count += 1;
}); });
expect(count, equals(0)); expect(count, equals(0));
await ui.channelBuffers.drain(channel, await ui.channelBuffers.drain(channel,
(ByteData data, ui.PlatformMessageResponseCallback callback) { (ByteData? data, ui.PlatformMessageResponseCallback callback) async {
callback(null); callback(null);
return null;
}); });
expect(count, equals(1)); expect(count, equals(1));
}); });
test('can check the handler', () { test('can check the handler', () {
Future<ByteData> handler(ByteData call) => Future<ByteData>.value(null); Future<ByteData> handler(ByteData? call) => Future<ByteData>.value(null);
final BinaryMessenger messenger = ServicesBinding.instance.defaultBinaryMessenger; final BinaryMessenger messenger = ServicesBinding.instance!.defaultBinaryMessenger;
expect(messenger.checkMessageHandler('test_channel', null), true); expect(messenger.checkMessageHandler('test_channel', null), true);
expect(messenger.checkMessageHandler('test_channel', handler), false); expect(messenger.checkMessageHandler('test_channel', handler), false);
...@@ -48,8 +45,8 @@ void main() { ...@@ -48,8 +45,8 @@ void main() {
}); });
test('can check the mock handler', () { test('can check the mock handler', () {
Future<ByteData> handler(ByteData call) => Future<ByteData>.value(null); Future<ByteData> handler(ByteData? call) => Future<ByteData>.value(null);
final BinaryMessenger messenger = ServicesBinding.instance.defaultBinaryMessenger; final BinaryMessenger messenger = ServicesBinding.instance!.defaultBinaryMessenger;
expect(messenger.checkMockMessageHandler('test_channel', null), true); expect(messenger.checkMockMessageHandler('test_channel', null), true);
expect(messenger.checkMockMessageHandler('test_channel', handler), false); expect(messenger.checkMockMessageHandler('test_channel', handler), false);
......
...@@ -2,8 +2,6 @@ ...@@ -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.8
import 'dart:async'; import 'dart:async';
import 'dart:typed_data'; import 'dart:typed_data';
...@@ -14,10 +12,7 @@ import 'package:flutter/widgets.dart'; ...@@ -14,10 +12,7 @@ import 'package:flutter/widgets.dart';
/// Used in internal testing. /// Used in internal testing.
class FakePlatformViewController extends PlatformViewController { class FakePlatformViewController extends PlatformViewController {
FakePlatformViewController(this.viewId);
FakePlatformViewController(int id) {
_id = id;
}
bool disposed = false; bool disposed = false;
bool focusCleared = false; bool focusCleared = false;
...@@ -25,10 +20,8 @@ class FakePlatformViewController extends PlatformViewController { ...@@ -25,10 +20,8 @@ class FakePlatformViewController extends PlatformViewController {
/// Events that are dispatched. /// Events that are dispatched.
List<PointerEvent> dispatchedPointerEvents = <PointerEvent>[]; List<PointerEvent> dispatchedPointerEvents = <PointerEvent>[];
int _id;
@override @override
int get viewId => _id; final int viewId;
@override @override
Future<void> dispatchPointerEvent(PointerEvent event) async { Future<void> dispatchPointerEvent(PointerEvent event) async {
...@@ -66,7 +59,7 @@ class FakeAndroidViewController implements AndroidViewController { ...@@ -66,7 +59,7 @@ class FakeAndroidViewController implements AndroidViewController {
final int viewId; final int viewId;
@override @override
Offset Function(Offset position) pointTransformer; Offset Function(Offset position)? pointTransformer;
@override @override
Future<void> dispatchPointerEvent(PointerEvent event) async { Future<void> dispatchPointerEvent(PointerEvent event) async {
...@@ -98,7 +91,7 @@ class FakeAndroidViewController implements AndroidViewController { ...@@ -98,7 +91,7 @@ class FakeAndroidViewController implements AndroidViewController {
int get textureId => throw UnimplementedError(); int get textureId => throw UnimplementedError();
@override @override
bool isCreated; bool get isCreated => throw UnimplementedError();
@override @override
void addOnPlatformViewCreatedListener(PlatformViewCreatedCallback listener) => void addOnPlatformViewCreatedListener(PlatformViewCreatedCallback listener) =>
...@@ -133,7 +126,6 @@ class FakeAndroidPlatformViewsController { ...@@ -133,7 +126,6 @@ class FakeAndroidPlatformViewsController {
SystemChannels.platform_views.setMockMethodCallHandler(_onMethodCall); SystemChannels.platform_views.setMockMethodCallHandler(_onMethodCall);
} }
Iterable<FakeAndroidPlatformView> get views => _views.values; Iterable<FakeAndroidPlatformView> get views => _views.values;
final Map<int, FakeAndroidPlatformView> _views = <int, FakeAndroidPlatformView>{}; final Map<int, FakeAndroidPlatformView> _views = <int, FakeAndroidPlatformView>{};
...@@ -143,11 +135,11 @@ class FakeAndroidPlatformViewsController { ...@@ -143,11 +135,11 @@ class FakeAndroidPlatformViewsController {
int _textureCounter = 0; int _textureCounter = 0;
Completer<void> resizeCompleter; Completer<void>? resizeCompleter;
Completer<void> createCompleter; Completer<void>? createCompleter;
int lastClearedFocusViewId; int? lastClearedFocusViewId;
void registerViewType(String viewType) { void registerViewType(String viewType) {
_registeredViewTypes.add(viewType); _registeredViewTypes.add(viewType);
...@@ -156,7 +148,8 @@ class FakeAndroidPlatformViewsController { ...@@ -156,7 +148,8 @@ class FakeAndroidPlatformViewsController {
void invokeViewFocused(int viewId) { void invokeViewFocused(int viewId) {
final MethodCodec codec = SystemChannels.platform_views.codec; final MethodCodec codec = SystemChannels.platform_views.codec;
final ByteData data = codec.encodeMethodCall(MethodCall('viewFocused', viewId)); final ByteData data = codec.encodeMethodCall(MethodCall('viewFocused', viewId));
ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage(SystemChannels.platform_views.name, data, (ByteData data) {}); ServicesBinding.instance!.defaultBinaryMessenger
.handlePlatformMessage(SystemChannels.platform_views.name, data, (ByteData? data) {});
} }
Future<dynamic> _onMethodCall(MethodCall call) { Future<dynamic> _onMethodCall(MethodCall call) {
...@@ -200,7 +193,7 @@ class FakeAndroidPlatformViewsController { ...@@ -200,7 +193,7 @@ class FakeAndroidPlatformViewsController {
); );
if (createCompleter != null) { if (createCompleter != null) {
await createCompleter.future; await createCompleter!.future;
} }
_views[id] = FakeAndroidPlatformView(id, viewType, _views[id] = FakeAndroidPlatformView(id, viewType,
...@@ -219,9 +212,9 @@ class FakeAndroidPlatformViewsController { ...@@ -219,9 +212,9 @@ class FakeAndroidPlatformViewsController {
final int id = call.arguments['id'] as int; final int id = call.arguments['id'] as int;
final bool hybrid = call.arguments['hybrid'] as bool; final bool hybrid = call.arguments['hybrid'] as bool;
if (hybrid && !_views[id].hybrid) { if (hybrid && !_views[id]!.hybrid!) {
throw ArgumentError('An $AndroidViewController using hybrid composition must pass `hybrid: true`'); throw ArgumentError('An $AndroidViewController using hybrid composition must pass `hybrid: true`');
} else if (!hybrid && _views[id].hybrid != null && _views[id].hybrid) { } else if (!hybrid && (_views[id]!.hybrid ?? false)) {
throw ArgumentError('An $AndroidViewController not using hybrid composition must pass `hybrid: false`'); throw ArgumentError('An $AndroidViewController not using hybrid composition must pass `hybrid: false`');
} }
...@@ -248,9 +241,9 @@ class FakeAndroidPlatformViewsController { ...@@ -248,9 +241,9 @@ class FakeAndroidPlatformViewsController {
); );
if (resizeCompleter != null) { if (resizeCompleter != null) {
await resizeCompleter.future; await resizeCompleter!.future;
} }
_views[id] = _views[id].copyWith(size: Size(width, height)); _views[id] = _views[id]!.copyWith(size: Size(width, height));
return Future<dynamic>.sync(() => null); return Future<dynamic>.sync(() => null);
} }
...@@ -273,7 +266,7 @@ class FakeAndroidPlatformViewsController { ...@@ -273,7 +266,7 @@ class FakeAndroidPlatformViewsController {
if (!motionEvents.containsKey(id)) if (!motionEvents.containsKey(id))
motionEvents[id] = <FakeAndroidMotionEvent> []; motionEvents[id] = <FakeAndroidMotionEvent> [];
motionEvents[id].add(FakeAndroidMotionEvent(action, pointerIds, pointerOffsets)); motionEvents[id]!.add(FakeAndroidMotionEvent(action, pointerIds, pointerOffsets));
return Future<dynamic>.sync(() => null); return Future<dynamic>.sync(() => null);
} }
...@@ -288,7 +281,7 @@ class FakeAndroidPlatformViewsController { ...@@ -288,7 +281,7 @@ class FakeAndroidPlatformViewsController {
message: 'Trying to resize a platform view with unknown id: $id', message: 'Trying to resize a platform view with unknown id: $id',
); );
_views[id] = _views[id].copyWith(layoutDirection: layoutDirection); _views[id] = _views[id]!.copyWith(layoutDirection: layoutDirection);
return Future<dynamic>.sync(() => null); return Future<dynamic>.sync(() => null);
} }
...@@ -312,7 +305,6 @@ class FakeIosPlatformViewsController { ...@@ -312,7 +305,6 @@ class FakeIosPlatformViewsController {
SystemChannels.platform_views.setMockMethodCallHandler(_onMethodCall); SystemChannels.platform_views.setMockMethodCallHandler(_onMethodCall);
} }
Iterable<FakeUiKitView> get views => _views.values; Iterable<FakeUiKitView> get views => _views.values;
final Map<int, FakeUiKitView> _views = <int, FakeUiKitView>{}; final Map<int, FakeUiKitView> _views = <int, FakeUiKitView>{};
...@@ -320,7 +312,7 @@ class FakeIosPlatformViewsController { ...@@ -320,7 +312,7 @@ class FakeIosPlatformViewsController {
// When this completer is non null, the 'create' method channel call will be // When this completer is non null, the 'create' method channel call will be
// delayed until it completes. // delayed until it completes.
Completer<void> creationDelay; Completer<void>? creationDelay;
// Maps a view id to the number of gestures it accepted so far. // Maps a view id to the number of gestures it accepted so far.
final Map<int, int> gesturesAccepted = <int, int>{}; final Map<int, int> gesturesAccepted = <int, int>{};
...@@ -348,7 +340,7 @@ class FakeIosPlatformViewsController { ...@@ -348,7 +340,7 @@ class FakeIosPlatformViewsController {
Future<dynamic> _create(MethodCall call) async { Future<dynamic> _create(MethodCall call) async {
if (creationDelay != null) if (creationDelay != null)
await creationDelay.future; await creationDelay!.future;
final Map<dynamic, dynamic> args = call.arguments as Map<dynamic, dynamic>; final Map<dynamic, dynamic> args = call.arguments as Map<dynamic, dynamic>;
final int id = args['id'] as int; final int id = args['id'] as int;
final String viewType = args['viewType'] as String; final String viewType = args['viewType'] as String;
...@@ -371,21 +363,21 @@ class FakeIosPlatformViewsController { ...@@ -371,21 +363,21 @@ class FakeIosPlatformViewsController {
_views[id] = FakeUiKitView(id, viewType, creationParams); _views[id] = FakeUiKitView(id, viewType, creationParams);
gesturesAccepted[id] = 0; gesturesAccepted[id] = 0;
gesturesRejected[id] = 0; gesturesRejected[id] = 0;
return Future<int>.sync(() => null); return Future<int?>.sync(() => null);
} }
Future<dynamic> _acceptGesture(MethodCall call) async { Future<dynamic> _acceptGesture(MethodCall call) async {
final Map<dynamic, dynamic> args = call.arguments as Map<dynamic, dynamic>; final Map<dynamic, dynamic> args = call.arguments as Map<dynamic, dynamic>;
final int id = args['id'] as int; final int id = args['id'] as int;
gesturesAccepted[id] += 1; gesturesAccepted[id] = gesturesAccepted[id]! + 1;
return Future<int>.sync(() => null); return Future<int?>.sync(() => null);
} }
Future<dynamic> _rejectGesture(MethodCall call) async { Future<dynamic> _rejectGesture(MethodCall call) async {
final Map<dynamic, dynamic> args = call.arguments as Map<dynamic, dynamic>; final Map<dynamic, dynamic> args = call.arguments as Map<dynamic, dynamic>;
final int id = args['id'] as int; final int id = args['id'] as int;
gesturesRejected[id] += 1; gesturesRejected[id] = gesturesRejected[id]! + 1;
return Future<int>.sync(() => null); return Future<int?>.sync(() => null);
} }
Future<dynamic> _dispose(MethodCall call) { Future<dynamic> _dispose(MethodCall call) {
...@@ -413,9 +405,9 @@ class FakeHtmlPlatformViewsController { ...@@ -413,9 +405,9 @@ class FakeHtmlPlatformViewsController {
final Set<String> _registeredViewTypes = <String>{}; final Set<String> _registeredViewTypes = <String>{};
Completer<void> resizeCompleter; late Completer<void> resizeCompleter;
Completer<void> createCompleter; Completer<void>? createCompleter;
void registerViewType(String viewType) { void registerViewType(String viewType) {
_registeredViewTypes.add(viewType); _registeredViewTypes.add(viewType);
...@@ -449,11 +441,11 @@ class FakeHtmlPlatformViewsController { ...@@ -449,11 +441,11 @@ class FakeHtmlPlatformViewsController {
); );
if (createCompleter != null) { if (createCompleter != null) {
await createCompleter.future; await createCompleter!.future;
} }
_views[id] = FakeHtmlPlatformView(id, viewType); _views[id] = FakeHtmlPlatformView(id, viewType);
return Future<int>.sync(() => null); return Future<int?>.sync(() => null);
} }
Future<dynamic> _dispose(MethodCall call) { Future<dynamic> _dispose(MethodCall call) {
...@@ -476,12 +468,12 @@ class FakeAndroidPlatformView { ...@@ -476,12 +468,12 @@ class FakeAndroidPlatformView {
final int id; final int id;
final String type; final String type;
final Uint8List creationParams; final Uint8List? creationParams;
final Size size; final Size? size;
final int layoutDirection; final int layoutDirection;
final bool hybrid; final bool? hybrid;
FakeAndroidPlatformView copyWith({Size size, int layoutDirection}) => FakeAndroidPlatformView( FakeAndroidPlatformView copyWith({Size? size, int? layoutDirection}) => FakeAndroidPlatformView(
id, id,
type, type,
size ?? this.size, size ?? this.size,
...@@ -544,7 +536,7 @@ class FakeUiKitView { ...@@ -544,7 +536,7 @@ class FakeUiKitView {
final int id; final int id;
final String type; final String type;
final Uint8List creationParams; final Uint8List? creationParams;
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
......
...@@ -2,8 +2,6 @@ ...@@ -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.8
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -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.8
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -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.8
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -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.8
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
...@@ -11,7 +9,7 @@ void main() { ...@@ -11,7 +9,7 @@ void main() {
testWidgets('initialLifecycleState is used to init state paused', (WidgetTester tester) async { testWidgets('initialLifecycleState is used to init state paused', (WidgetTester tester) async {
// The lifecycleState is null initially in tests as there is no // The lifecycleState is null initially in tests as there is no
// initialLifecycleState. // initialLifecycleState.
expect(ServicesBinding.instance.lifecycleState, equals(null)); expect(ServicesBinding.instance!.lifecycleState, equals(null));
// Mock the Window to provide paused as the AppLifecycleState // Mock the Window to provide paused as the AppLifecycleState
final TestWidgetsFlutterBinding binding = tester.binding; final TestWidgetsFlutterBinding binding = tester.binding;
// Use paused as the initial state. // Use paused as the initial state.
...@@ -20,6 +18,6 @@ void main() { ...@@ -20,6 +18,6 @@ void main() {
// The lifecycleState should now be the state we passed above, // The lifecycleState should now be the state we passed above,
// even though no lifecycle event was fired from the platform. // even though no lifecycle event was fired from the platform.
expect(ServicesBinding.instance.lifecycleState.toString(), equals('AppLifecycleState.paused')); expect(ServicesBinding.instance!.lifecycleState.toString(), equals('AppLifecycleState.paused'));
}); });
} }
...@@ -2,8 +2,6 @@ ...@@ -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.8
// This files contains message codec tests that are supported both on the Web // This files contains message codec tests that are supported both on the Web
// and in the VM. For VM-only tests see message_codecs_vm_test.dart. // and in the VM. For VM-only tests see message_codecs_vm_test.dart.
...@@ -18,26 +16,25 @@ import 'message_codecs_testing.dart'; ...@@ -18,26 +16,25 @@ import 'message_codecs_testing.dart';
void main() { void main() {
group('Binary codec', () { group('Binary codec', () {
const MessageCodec<ByteData> binary = BinaryCodec(); const MessageCodec<ByteData?> binary = BinaryCodec();
test('should encode and decode simple messages', () { test('should encode and decode simple messages', () {
checkEncodeDecode<ByteData>(binary, null); checkEncodeDecode<ByteData?>(binary, null);
checkEncodeDecode<ByteData>(binary, ByteData(0)); checkEncodeDecode<ByteData?>(binary, ByteData(0));
checkEncodeDecode<ByteData>(binary, ByteData(4)..setInt32(0, -7)); checkEncodeDecode<ByteData?>(binary, ByteData(4)..setInt32(0, -7));
}); });
}); });
group('String codec', () { group('String codec', () {
const MessageCodec<String> string = StringCodec(); const MessageCodec<String?> string = StringCodec();
test('should encode and decode simple messages', () { test('should encode and decode simple messages', () {
checkEncodeDecode<String>(string, null); checkEncodeDecode<String?>(string, null);
checkEncodeDecode<String>(string, ''); checkEncodeDecode<String?>(string, '');
checkEncodeDecode<String>(string, 'hello'); checkEncodeDecode<String?>(string, 'hello');
checkEncodeDecode<String>(string, 'special chars >\u263A\u{1F602}<'); checkEncodeDecode<String?>(string, 'special chars >\u263A\u{1F602}<');
}); });
test('ByteData with offset', () { test('ByteData with offset', () {
const MessageCodec<String> string = StringCodec(); const MessageCodec<String?> string = StringCodec();
final ByteData helloWorldByteData = string.encodeMessage('hello world'); final ByteData helloWorldByteData = string.encodeMessage('hello world')!;
final ByteData helloByteData = string.encodeMessage('hello'); final ByteData helloByteData = string.encodeMessage('hello')!;
final ByteData offsetByteData = ByteData.view( final ByteData offsetByteData = ByteData.view(
helloWorldByteData.buffer, helloWorldByteData.buffer,
helloByteData.lengthInBytes, helloByteData.lengthInBytes,
...@@ -97,7 +94,7 @@ void main() { ...@@ -97,7 +94,7 @@ void main() {
e.details == 'errorDetails'))); e.details == 'errorDetails')));
}); });
test('should decode error envelope with native stacktrace.', () { test('should decode error envelope with native stacktrace.', () {
final ByteData errorData = stringCodec.encodeMessage(json final ByteData? errorData = stringCodec.encodeMessage(json
.encode(<dynamic>[ .encode(<dynamic>[
'errorCode', 'errorCode',
'errorMessage', 'errorMessage',
...@@ -105,7 +102,7 @@ void main() { ...@@ -105,7 +102,7 @@ void main() {
'errorStacktrace' 'errorStacktrace'
])); ]));
expect( expect(
() => jsonMethodCodec.decodeEnvelope(errorData), () => jsonMethodCodec.decodeEnvelope(errorData!),
throwsA(predicate((PlatformException e) => throwsA(predicate((PlatformException e) =>
e is PlatformException && e.stacktrace == 'errorStacktrace'))); e is PlatformException && e.stacktrace == 'errorStacktrace')));
}); });
......
...@@ -23,9 +23,9 @@ void checkEncodeDecode<T>(MessageCodec<T> codec, T message) { ...@@ -23,9 +23,9 @@ void checkEncodeDecode<T>(MessageCodec<T> codec, T message) {
expect(decoded, isNull); expect(decoded, isNull);
} else { } else {
expect(deepEquals(message, decoded), isTrue); expect(deepEquals(message, decoded), isTrue);
final ByteData encodedAgain = codec.encodeMessage(decoded)!; final ByteData? encodedAgain = codec.encodeMessage(decoded);
expect( expect(
encodedAgain.buffer.asUint8List(), encodedAgain!.buffer.asUint8List(),
orderedEquals(encoded!.buffer.asUint8List()), orderedEquals(encoded!.buffer.asUint8List()),
); );
} }
......
...@@ -2,7 +2,6 @@ ...@@ -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.8
// This file contains tests that are only supported by the Dart VM. For // This file contains tests that are only supported by the Dart VM. For
// example, on the Web there's no way to express large integers. // example, on the Web there's no way to express large integers.
......
...@@ -2,7 +2,6 @@ ...@@ -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.8
@TestOn('!chrome') // missing web infrastructure for plugins. @TestOn('!chrome') // missing web infrastructure for plugins.
...@@ -16,20 +15,20 @@ void main() { ...@@ -16,20 +15,20 @@ void main() {
// Initialize all bindings because defaultBinaryMessenger.send() needs a window. // Initialize all bindings because defaultBinaryMessenger.send() needs a window.
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
final List<ByteData> log = <ByteData>[]; final List<ByteData?> log = <ByteData>[];
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler('test1', (ByteData message) async { ServicesBinding.instance!.defaultBinaryMessenger.setMockMessageHandler('test1', (ByteData? message) async {
log.add(message); log.add(message);
return null; return null;
}); });
final ByteData message = ByteData(2)..setUint16(0, 0xABCD); final ByteData message = ByteData(2)..setUint16(0, 0xABCD);
await ServicesBinding.instance.defaultBinaryMessenger.send('test1', message); await ServicesBinding.instance!.defaultBinaryMessenger.send('test1', message);
expect(log, equals(<ByteData>[message])); expect(log, equals(<ByteData>[message]));
log.clear(); log.clear();
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler('test1', null); ServicesBinding.instance!.defaultBinaryMessenger.setMockMessageHandler('test1', null);
await ServicesBinding.instance.defaultBinaryMessenger.send('test1', message); await ServicesBinding.instance!.defaultBinaryMessenger.send('test1', message);
expect(log, isEmpty); expect(log, isEmpty);
}); });
} }
...@@ -2,7 +2,6 @@ ...@@ -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.8
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
...@@ -15,7 +14,7 @@ void main() { ...@@ -15,7 +14,7 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
group('Android', () { group('Android', () {
FakeAndroidPlatformViewsController viewsController; late FakeAndroidPlatformViewsController viewsController;
setUp(() { setUp(() {
viewsController = FakeAndroidPlatformViewsController(); viewsController = FakeAndroidPlatformViewsController();
}); });
...@@ -202,7 +201,7 @@ void main() { ...@@ -202,7 +201,7 @@ void main() {
}); });
group('iOS', () { group('iOS', () {
FakeIosPlatformViewsController viewsController; late FakeIosPlatformViewsController viewsController;
setUp(() { setUp(() {
viewsController = FakeIosPlatformViewsController(); viewsController = FakeIosPlatformViewsController();
}); });
......
...@@ -2,7 +2,6 @@ ...@@ -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.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
...@@ -54,7 +53,7 @@ void main() { ...@@ -54,7 +53,7 @@ void main() {
expect(manager.updateScheduled, isFalse); expect(manager.updateScheduled, isFalse);
// Can store null. // Can store null.
bucket.write<bool>('value4', null); bucket.write<bool?>('value4', null);
expect(manager.updateScheduled, isTrue); expect(manager.updateScheduled, isTrue);
expect(bucket.read<int>('value4'), null); expect(bucket.read<int>('value4'), null);
manager.doSerialization(); manager.doSerialization();
...@@ -111,7 +110,7 @@ void main() { ...@@ -111,7 +110,7 @@ void main() {
expect(manager.updateScheduled, isFalse); expect(manager.updateScheduled, isFalse);
// Can store null. // Can store null.
child.write<bool>('value4', null); child.write<bool?>('value4', null);
expect(manager.updateScheduled, isTrue); expect(manager.updateScheduled, isTrue);
expect(child.read<int>('value4'), null); expect(child.read<int>('value4'), null);
manager.doSerialization(); manager.doSerialization();
...@@ -327,7 +326,7 @@ void main() { ...@@ -327,7 +326,7 @@ void main() {
final RestorationBucket root = RestorationBucket.root(manager: manager, rawData: rawData); final RestorationBucket root = RestorationBucket.root(manager: manager, rawData: rawData);
final RestorationBucket child = root.claimChild('child1', debugOwner: 'owner1'); final RestorationBucket child = root.claimChild('child1', debugOwner: 'owner1');
final Object rawChildData = rawData[childrenMapKey]['child1']; final Object rawChildData = rawData[childrenMapKey]['child1'] as Object;
expect(rawChildData, isNotNull); expect(rawChildData, isNotNull);
expect(manager.updateScheduled, isFalse); expect(manager.updateScheduled, isFalse);
...@@ -370,9 +369,9 @@ void main() { ...@@ -370,9 +369,9 @@ void main() {
final RestorationBucket child2 = root.claimChild('child2', debugOwner: 'owner1'); final RestorationBucket child2 = root.claimChild('child2', debugOwner: 'owner1');
manager.doSerialization(); manager.doSerialization();
final Object rawChild1Data = rawData[childrenMapKey]['child1']; final Object rawChild1Data = rawData[childrenMapKey]['child1'] as Object;
expect(rawChild1Data, isNotNull); expect(rawChild1Data, isNotNull);
final Object rawChild2Data = rawData[childrenMapKey]['child2']; final Object rawChild2Data = rawData[childrenMapKey]['child2'] as Object;
expect(rawChild2Data, isNotNull); expect(rawChild2Data, isNotNull);
expect(child1.restorationId, 'child1'); expect(child1.restorationId, 'child1');
...@@ -396,7 +395,7 @@ void main() { ...@@ -396,7 +395,7 @@ void main() {
final Map<String, dynamic> rawData = _createRawDataSet(); final Map<String, dynamic> rawData = _createRawDataSet();
final RestorationBucket root = RestorationBucket.root(manager: manager, rawData: rawData); final RestorationBucket root = RestorationBucket.root(manager: manager, rawData: rawData);
final Object rawChild1Data = rawData[childrenMapKey]['child1']; final Object rawChild1Data = rawData[childrenMapKey]['child1'] as Object;
expect(rawChild1Data, isNotNull); expect(rawChild1Data, isNotNull);
final RestorationBucket child1 = root.claimChild('child1', debugOwner: 'owner1'); final RestorationBucket child1 = root.claimChild('child1', debugOwner: 'owner1');
...@@ -462,7 +461,7 @@ void main() { ...@@ -462,7 +461,7 @@ void main() {
manager.doSerialization(); manager.doSerialization();
expect(manager.updateScheduled, isFalse); expect(manager.updateScheduled, isFalse);
final Object childOfChildData = rawData[childrenMapKey]['child1'][childrenMapKey]['childOfChild']; final Object childOfChildData = rawData[childrenMapKey]['child1'][childrenMapKey]['childOfChild'] as Object;
expect(childOfChildData, isNotEmpty); expect(childOfChildData, isNotEmpty);
root.adoptChild(childOfChild); root.adoptChild(childOfChild);
...@@ -497,7 +496,7 @@ void main() { ...@@ -497,7 +496,7 @@ void main() {
final RestorationBucket childOfChild = child.claimChild('child1', debugOwner: 'owner2'); final RestorationBucket childOfChild = child.claimChild('child1', debugOwner: 'owner2');
childOfChild.write<String>('foo', 'bar'); childOfChild.write<String>('foo', 'bar');
final Object childOfChildData = rawData[childrenMapKey]['child1'][childrenMapKey]['child1']; final Object childOfChildData = rawData[childrenMapKey]['child1'][childrenMapKey]['child1'] as Object;
expect(childOfChildData, isNotEmpty); expect(childOfChildData, isNotEmpty);
expect(manager.updateScheduled, isTrue); expect(manager.updateScheduled, isTrue);
......
...@@ -2,7 +2,6 @@ ...@@ -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.8
import 'dart:typed_data'; import 'dart:typed_data';
...@@ -61,11 +60,10 @@ void main() { ...@@ -61,11 +60,10 @@ void main() {
}); });
test('setApplicationSwitcherDescription missing plugin', () async { test('setApplicationSwitcherDescription missing plugin', () async {
final List<ByteData> log = <ByteData>[]; final List<ByteData?> log = <ByteData>[];
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler('flutter/platform', (ByteData message) { ServicesBinding.instance!.defaultBinaryMessenger.setMockMessageHandler('flutter/platform', (ByteData? message) async {
log.add(message); log.add(message);
return null;
}); });
await SystemChrome.setApplicationSwitcherDescription( await SystemChrome.setApplicationSwitcherDescription(
......
...@@ -2,7 +2,6 @@ ...@@ -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.8
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
......
...@@ -2,7 +2,6 @@ ...@@ -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.8
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
......
...@@ -2,27 +2,25 @@ ...@@ -2,27 +2,25 @@
// 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.8
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
TextEditingValue testOldValue; TextEditingValue testOldValue = TextEditingValue.empty;
TextEditingValue testNewValue; TextEditingValue testNewValue = TextEditingValue.empty;
test('withFunction wraps formatting function', () { test('withFunction wraps formatting function', () {
testOldValue = const TextEditingValue(); testOldValue = const TextEditingValue();
testNewValue = const TextEditingValue(); testNewValue = const TextEditingValue();
TextEditingValue calledOldValue; late TextEditingValue calledOldValue;
TextEditingValue calledNewValue; late TextEditingValue calledNewValue;
final TextInputFormatter formatterUnderTest = TextInputFormatter.withFunction( final TextInputFormatter formatterUnderTest = TextInputFormatter.withFunction(
(TextEditingValue oldValue, TextEditingValue newValue) { (TextEditingValue oldValue, TextEditingValue newValue) {
calledOldValue = oldValue; calledOldValue = oldValue;
calledNewValue = newValue; calledNewValue = newValue;
return null; return TextEditingValue.empty;
} }
); );
......
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