[null-safety] update to several framework test cases/APIs for null assertions (#62946)
This commit is contained in:
@@ -2053,7 +2053,7 @@ class PercentProperty extends DoubleProperty {
|
||||
/// The [showName] and [level] arguments must not be null.
|
||||
PercentProperty(
|
||||
String name,
|
||||
double fraction, {
|
||||
double? fraction, {
|
||||
String? ifNull,
|
||||
bool showName = true,
|
||||
String? tooltip,
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
|
||||
import 'dart:developer';
|
||||
import 'dart:ui' show hashValues;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ abstract class BinaryMessenger {
|
||||
///
|
||||
/// 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.
|
||||
bool checkMessageHandler(String channel, MessageHandler handler);
|
||||
bool checkMessageHandler(String channel, MessageHandler? handler);
|
||||
|
||||
/// Set a mock callback for intercepting messages from the [send] method on
|
||||
/// this class, on the given channel, without decoding them.
|
||||
@@ -70,7 +70,7 @@ abstract class BinaryMessenger {
|
||||
/// 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
|
||||
/// test.
|
||||
bool checkMockMessageHandler(String channel, MessageHandler handler);
|
||||
bool checkMockMessageHandler(String channel, MessageHandler? handler);
|
||||
}
|
||||
|
||||
/// The default instance of [BinaryMessenger].
|
||||
|
||||
@@ -216,8 +216,8 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
|
||||
/// To use a different [RestorationManager] subclasses can override
|
||||
/// [createRestorationManager], which is called to create the instance
|
||||
/// returned by this getter.
|
||||
RestorationManager get restorationManager => _restorationManager;
|
||||
late RestorationManager _restorationManager;
|
||||
RestorationManager get restorationManager => _restorationManager!;
|
||||
RestorationManager? _restorationManager;
|
||||
|
||||
/// Creates the [RestorationManager] instance available via
|
||||
/// [restorationManager].
|
||||
@@ -319,7 +319,7 @@ class _DefaultBinaryMessenger extends BinaryMessenger {
|
||||
}
|
||||
|
||||
@override
|
||||
bool checkMessageHandler(String channel, MessageHandler handler) => _handlers[channel] == handler;
|
||||
bool checkMessageHandler(String channel, MessageHandler? handler) => _handlers[channel] == handler;
|
||||
|
||||
@override
|
||||
void setMockMessageHandler(String channel, MessageHandler? handler) {
|
||||
@@ -330,5 +330,5 @@ class _DefaultBinaryMessenger extends BinaryMessenger {
|
||||
}
|
||||
|
||||
@override
|
||||
bool checkMockMessageHandler(String channel, MessageHandler handler) => _mockHandlers[channel] == handler;
|
||||
bool checkMockMessageHandler(String channel, MessageHandler? handler) => _mockHandlers[channel] == handler;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
|
||||
|
||||
@@ -210,8 +210,8 @@ void main() {
|
||||
test('Cannot use a disposed ChangeNotifier', () {
|
||||
final TestNotifier source = TestNotifier();
|
||||
source.dispose();
|
||||
expect(() { source.addListener(null); }, throwsFlutterError);
|
||||
expect(() { source.removeListener(null); }, throwsFlutterError);
|
||||
expect(() { source.addListener(() { }); }, throwsFlutterError);
|
||||
expect(() { source.removeListener(() { }); }, throwsFlutterError);
|
||||
expect(() { source.dispose(); }, throwsFlutterError);
|
||||
expect(() { source.notify(); }, throwsFlutterError);
|
||||
});
|
||||
|
||||
@@ -136,7 +136,9 @@ void main() {
|
||||
final File file = fs.file('/empty.png')..createSync(recursive: true);
|
||||
final FileImage provider = FileImage(file);
|
||||
|
||||
expect(provider.load(provider, null), isA<MultiFrameImageStreamCompleter>());
|
||||
expect(provider.load(provider, (Uint8List bytes, {int cacheWidth, int cacheHeight, bool allowUpscaling}) async {
|
||||
return Future<Codec>.value(FakeCodec());
|
||||
}), isA<MultiFrameImageStreamCompleter>());
|
||||
|
||||
expect(await error.future, isStateError);
|
||||
});
|
||||
|
||||
@@ -96,7 +96,7 @@ void main() {
|
||||
Ticker ticker;
|
||||
|
||||
void testFunction() {
|
||||
ticker = Ticker(null);
|
||||
ticker = Ticker((Duration _) { });
|
||||
}
|
||||
|
||||
testFunction();
|
||||
|
||||
@@ -194,7 +194,7 @@ void main() {
|
||||
testWidgets('scheduleFrameCallback error control test', (WidgetTester tester) async {
|
||||
FlutterError error;
|
||||
try {
|
||||
tester.binding.scheduleFrameCallback(null, rescheduling: true);
|
||||
tester.binding.scheduleFrameCallback((Duration _) { }, rescheduling: true);
|
||||
} on FlutterError catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
@@ -797,12 +797,12 @@ void main() {
|
||||
expect(listeners.length, 2);
|
||||
|
||||
// Make sure the first listener can be called re-entrantly
|
||||
listeners[1].onImage(null, null);
|
||||
listeners[1].onImage(null, null);
|
||||
listeners[1].onImage(null, false);
|
||||
listeners[1].onImage(null, false);
|
||||
|
||||
// Make sure the second listener can be called re-entrantly.
|
||||
listeners[0].onImage(null, null);
|
||||
listeners[0].onImage(null, null);
|
||||
listeners[0].onImage(null, false);
|
||||
listeners[0].onImage(null, false);
|
||||
});
|
||||
|
||||
testWidgets('Precache completes with onError on error', (WidgetTester tester) async {
|
||||
|
||||
@@ -190,7 +190,7 @@ class TestWindow implements Window {
|
||||
|
||||
@override
|
||||
String get initialLifecycleState => _initialLifecycleStateTestValue;
|
||||
String _initialLifecycleStateTestValue;
|
||||
String _initialLifecycleStateTestValue = '';
|
||||
/// Sets a faked initialLifecycleState for testing.
|
||||
set initialLifecycleStateTestValue(String state) {
|
||||
_initialLifecycleStateTestValue = state;
|
||||
|
||||
Reference in New Issue
Block a user