diff --git a/packages/flutter_driver/lib/src/common/diagnostics_tree.dart b/packages/flutter_driver/lib/src/common/diagnostics_tree.dart index bf35445a07..dbe5b649de 100644 --- a/packages/flutter_driver/lib/src/common/diagnostics_tree.dart +++ b/packages/flutter_driver/lib/src/common/diagnostics_tree.dart @@ -28,8 +28,7 @@ class GetDiagnosticsTree extends CommandWithTarget { this.subtreeDepth = 0, this.includeProperties = true, super.timeout, - }) : assert(subtreeDepth != null), - assert(includeProperties != null); + }); /// Deserializes this command from the value generated by [serialize]. GetDiagnosticsTree.deserialize(super.json, super.finderFactory) diff --git a/packages/flutter_driver/lib/src/common/find.dart b/packages/flutter_driver/lib/src/common/find.dart index d03b0ee9ea..326455a0ba 100644 --- a/packages/flutter_driver/lib/src/common/find.dart +++ b/packages/flutter_driver/lib/src/common/find.dart @@ -23,9 +23,7 @@ DriverError _createInvalidKeyValueTypeError(String invalidType) { /// and add more keys to the returned map. abstract class CommandWithTarget extends Command { /// Constructs this command given a [finder]. - CommandWithTarget(this.finder, {super.timeout}) { - assert(finder != null, '$runtimeType target cannot be null'); - } + CommandWithTarget(this.finder, {super.timeout}); /// Deserializes this command from the value generated by [serialize]. CommandWithTarget.deserialize(super.json, DeserializeFinderFactory finderFactory) diff --git a/packages/flutter_driver/lib/src/common/handler_factory.dart b/packages/flutter_driver/lib/src/common/handler_factory.dart index 6289da676e..5960f7557c 100644 --- a/packages/flutter_driver/lib/src/common/handler_factory.dart +++ b/packages/flutter_driver/lib/src/common/handler_factory.dart @@ -260,7 +260,6 @@ mixin CommandHandlerFactory { } Future _waitForCondition(Command command) async { - assert(command != null); final WaitForCondition waitForConditionCommand = command as WaitForCondition; final WaitCondition condition = deserializeCondition(waitForConditionCommand.condition); await condition.wait(); diff --git a/packages/flutter_driver/lib/src/common/health.dart b/packages/flutter_driver/lib/src/common/health.dart index f56723cee9..c0a400f8ff 100644 --- a/packages/flutter_driver/lib/src/common/health.dart +++ b/packages/flutter_driver/lib/src/common/health.dart @@ -36,8 +36,7 @@ final EnumIndex _healthStatusIndex = /// [FlutterDriver.checkHealth] test. class Health extends Result { /// Creates a [Health] object with the given [status]. - const Health(this.status) - : assert(status != null); + const Health(this.status); /// The status represented by this object. /// diff --git a/packages/flutter_driver/lib/src/common/wait.dart b/packages/flutter_driver/lib/src/common/wait.dart index d31560087b..5d9e86fefb 100644 --- a/packages/flutter_driver/lib/src/common/wait.dart +++ b/packages/flutter_driver/lib/src/common/wait.dart @@ -11,15 +11,13 @@ class WaitForCondition extends Command { /// Creates a command that waits for the given [condition] is met. /// /// The [condition] argument must not be null. - const WaitForCondition(this.condition, {super.timeout}) - : assert(condition != null); + const WaitForCondition(this.condition, {super.timeout}); /// Deserializes this command from the value generated by [serialize]. /// /// The [json] argument cannot be null. WaitForCondition.deserialize(super.json) - : assert(json != null), - condition = _deserialize(json), + : condition = _deserialize(json), super.deserialize(); /// The condition that this command shall wait for. @@ -94,7 +92,6 @@ class NoTransientCallbacks extends SerializableWaitCondition { /// /// The [json] argument must not be null. factory NoTransientCallbacks.deserialize(Map json) { - assert(json != null); if (json['conditionName'] != 'NoTransientCallbacksCondition') { throw SerializationException('Error occurred during deserializing the NoTransientCallbacksCondition JSON string: $json'); } @@ -115,7 +112,6 @@ class NoPendingFrame extends SerializableWaitCondition { /// /// The [json] argument must not be null. factory NoPendingFrame.deserialize(Map json) { - assert(json != null); if (json['conditionName'] != 'NoPendingFrameCondition') { throw SerializationException('Error occurred during deserializing the NoPendingFrameCondition JSON string: $json'); } @@ -136,7 +132,6 @@ class FirstFrameRasterized extends SerializableWaitCondition { /// /// The [json] argument must not be null. factory FirstFrameRasterized.deserialize(Map json) { - assert(json != null); if (json['conditionName'] != 'FirstFrameRasterizedCondition') { throw SerializationException('Error occurred during deserializing the FirstFrameRasterizedCondition JSON string: $json'); } @@ -160,7 +155,6 @@ class NoPendingPlatformMessages extends SerializableWaitCondition { /// /// The [json] argument must not be null. factory NoPendingPlatformMessages.deserialize(Map json) { - assert(json != null); if (json['conditionName'] != 'NoPendingPlatformMessagesCondition') { throw SerializationException('Error occurred during deserializing the NoPendingPlatformMessagesCondition JSON string: $json'); } @@ -176,15 +170,13 @@ class CombinedCondition extends SerializableWaitCondition { /// Creates a [CombinedCondition] condition. /// /// The [conditions] argument must not be null. - const CombinedCondition(this.conditions) - : assert(conditions != null); + const CombinedCondition(this.conditions); /// Factory constructor to parse a [CombinedCondition] instance from the /// given JSON map. /// /// The [jsonMap] argument must not be null. factory CombinedCondition.deserialize(Map jsonMap) { - assert(jsonMap != null); if (jsonMap['conditionName'] != 'CombinedCondition') { throw SerializationException('Error occurred during deserializing the CombinedCondition JSON string: $jsonMap'); } @@ -210,7 +202,6 @@ class CombinedCondition extends SerializableWaitCondition { final Map jsonMap = super.serialize(); final List> jsonConditions = conditions.map( (SerializableWaitCondition condition) { - assert(condition != null); return condition.serialize(); }).toList(); jsonMap['conditions'] = json.encode(jsonConditions); @@ -222,7 +213,6 @@ class CombinedCondition extends SerializableWaitCondition { /// /// The [json] argument must not be null. SerializableWaitCondition _deserialize(Map json) { - assert(json != null); final String conditionName = json['conditionName']!; switch (conditionName) { case 'NoTransientCallbacksCondition': diff --git a/packages/flutter_driver/lib/src/driver/driver.dart b/packages/flutter_driver/lib/src/driver/driver.dart index 33cc9dee41..b29becca68 100644 --- a/packages/flutter_driver/lib/src/driver/driver.dart +++ b/packages/flutter_driver/lib/src/driver/driver.dart @@ -432,11 +432,6 @@ abstract class FlutterDriver { double dyScroll = 0.0, Duration? timeout, }) async { - assert(scrollable != null); - assert(item != null); - assert(alignment != null); - assert(dxScroll != null); - assert(dyScroll != null); assert(dxScroll != 0.0 || dyScroll != 0.0); // Kick off an (unawaited) waitFor that will complete when the item we're @@ -509,7 +504,6 @@ abstract class FlutterDriver { /// invoked when the widget is focused, as the [SystemChannels.textInput] /// channel will be mocked out. Future setTextEntryEmulation({ required bool enabled, Duration? timeout }) async { - assert(enabled != null); await sendCommand(SetTextEntryEmulation(enabled, timeout: timeout)); } @@ -537,7 +531,6 @@ abstract class FlutterDriver { /// Future sendTextInputAction(TextInputAction action, {Duration? timeout}) async { - assert(action != null); await sendCommand(SendTextInputAction(action, timeout: timeout)); } diff --git a/packages/flutter_driver/lib/src/driver/vmservice_driver.dart b/packages/flutter_driver/lib/src/driver/vmservice_driver.dart index ec76c97de1..33c8140dc5 100644 --- a/packages/flutter_driver/lib/src/driver/vmservice_driver.dart +++ b/packages/flutter_driver/lib/src/driver/vmservice_driver.dart @@ -144,7 +144,7 @@ class VMServiceFlutterDriver extends FlutterDriver { // Let subsequent isolates start automatically. try { final vms.Response result = await client.setFlag('pause_isolates_on_start', 'false'); - if (result == null || result.type != 'Success') { + if (result.type != 'Success') { _log('setFlag failure: $result'); } } catch (e) { @@ -348,7 +348,6 @@ class VMServiceFlutterDriver extends FlutterDriver { _log(message); } if (_logCommunicationToFile) { - assert(_logFilePathName != null); final f.File file = fs.file(_logFilePathName); file.createSync(recursive: true); // no-op if file exists file.writeAsStringSync('${DateTime.now()} $message\n', mode: f.FileMode.append, flush: true); @@ -380,8 +379,7 @@ class VMServiceFlutterDriver extends FlutterDriver { List streams = const [TimelineStream.all], Duration timeout = kUnusuallyLongTimeout, }) async { - assert(streams != null && streams.isNotEmpty); - assert(timeout != null); + assert(streams.isNotEmpty); try { await _warnIfSlow( future: _serviceClient.setVMTimelineFlags( @@ -405,7 +403,6 @@ class VMServiceFlutterDriver extends FlutterDriver { int? startTime, int? endTime, }) async { - assert(timeout != null); assert((startTime == null && endTime == null) || (startTime != null && endTime != null)); @@ -497,7 +494,6 @@ class VMServiceFlutterDriver extends FlutterDriver { Future clearTimeline({ Duration timeout = kUnusuallyLongTimeout, }) async { - assert(timeout != null); try { await _warnIfSlow( future: _serviceClient.clearVMTimeline(), @@ -630,9 +626,6 @@ Future _warnIfSlow({ required Duration timeout, required String message, }) async { - assert(future != null); - assert(timeout != null); - assert(message != null); final Completer completer = Completer(); completer.future.timeout(timeout, onTimeout: () { _log(message); diff --git a/packages/flutter_driver/lib/src/driver/web_driver.dart b/packages/flutter_driver/lib/src/driver/web_driver.dart index 3927cbc397..a233f659f3 100644 --- a/packages/flutter_driver/lib/src/driver/web_driver.dart +++ b/packages/flutter_driver/lib/src/driver/web_driver.dart @@ -174,7 +174,6 @@ class WebFlutterDriver extends FlutterDriver { driverLog('WebFlutterDriver', message); } if (_logCommunicationToFile) { - assert(_logFilePathName != null); final File file = fs.file(_logFilePathName); file.createSync(recursive: true); // no-op if file exists file.writeAsStringSync('${DateTime.now()} $message\n', mode: FileMode.append, flush: true); diff --git a/packages/flutter_driver/lib/src/extension/extension.dart b/packages/flutter_driver/lib/src/extension/extension.dart index 5ac8f48a8c..e8f33b3c1c 100644 --- a/packages/flutter_driver/lib/src/extension/extension.dart +++ b/packages/flutter_driver/lib/src/extension/extension.dart @@ -319,7 +319,7 @@ class FlutterDriverExtension with DeserializeFinderFactory, CreateFinderFactory, this._enableTextEntryEmulation, { List finders = const [], List commands = const [], - }) : assert(finders != null) { + }) { if (_enableTextEntryEmulation) { registerTextInput(); } diff --git a/packages/flutter_driver/lib/src/extension/wait_conditions.dart b/packages/flutter_driver/lib/src/extension/wait_conditions.dart index c958b16fc5..1f61bcc1ca 100644 --- a/packages/flutter_driver/lib/src/extension/wait_conditions.dart +++ b/packages/flutter_driver/lib/src/extension/wait_conditions.dart @@ -42,7 +42,6 @@ class _InternalNoTransientCallbacksCondition implements WaitCondition { /// /// The [condition] argument must not be null. factory _InternalNoTransientCallbacksCondition.deserialize(SerializableWaitCondition condition) { - assert(condition != null); if (condition.conditionName != 'NoTransientCallbacksCondition') { throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}'); } @@ -71,7 +70,6 @@ class _InternalNoPendingFrameCondition implements WaitCondition { /// /// The [condition] argument must not be null. factory _InternalNoPendingFrameCondition.deserialize(SerializableWaitCondition condition) { - assert(condition != null); if (condition.conditionName != 'NoPendingFrameCondition') { throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}'); } @@ -100,7 +98,6 @@ class _InternalFirstFrameRasterizedCondition implements WaitCondition { /// /// The [condition] argument must not be null. factory _InternalFirstFrameRasterizedCondition.deserialize(SerializableWaitCondition condition) { - assert(condition != null); if (condition.conditionName != 'FirstFrameRasterizedCondition') { throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}'); } @@ -127,7 +124,6 @@ class _InternalNoPendingPlatformMessagesCondition implements WaitCondition { /// /// The [condition] argument must not be null. factory _InternalNoPendingPlatformMessagesCondition.deserialize(SerializableWaitCondition condition) { - assert(condition != null); if (condition.conditionName != 'NoPendingPlatformMessagesCondition') { throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}'); } @@ -156,15 +152,13 @@ class _InternalCombinedCondition implements WaitCondition { /// [conditions]. /// /// The [conditions] argument must not be null. - const _InternalCombinedCondition(this.conditions) - : assert(conditions != null); + const _InternalCombinedCondition(this.conditions); /// Factory constructor to parse an [_InternalCombinedCondition] instance from /// the given [SerializableWaitCondition] instance. /// /// The [condition] argument must not be null. factory _InternalCombinedCondition.deserialize(SerializableWaitCondition condition) { - assert(condition != null); if (condition.conditionName != 'CombinedCondition') { throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}'); } @@ -185,7 +179,6 @@ class _InternalCombinedCondition implements WaitCondition { Future wait() async { while (!condition) { for (final WaitCondition condition in conditions) { - assert (condition != null); await condition.wait(); } } @@ -197,7 +190,6 @@ class _InternalCombinedCondition implements WaitCondition { /// /// The [waitCondition] argument must not be null. WaitCondition deserializeCondition(SerializableWaitCondition waitCondition) { - assert(waitCondition != null); final String conditionName = waitCondition.conditionName; switch (conditionName) { case 'NoTransientCallbacksCondition': diff --git a/packages/flutter_driver/test/src/real_tests/flutter_driver_test.dart b/packages/flutter_driver/test/src/real_tests/flutter_driver_test.dart index 894c280b71..d675027f17 100644 --- a/packages/flutter_driver/test/src/real_tests/flutter_driver_test.dart +++ b/packages/flutter_driver/test/src/real_tests/flutter_driver_test.dart @@ -1193,9 +1193,9 @@ class FakeVmService extends Fake implements vms.VmService { commandLog.add('$method $args'); await artificialExtensionDelay; - final vms.Response response = responses[args!['command']]!; + final vms.Response? response = responses[args!['command']]; assert(response != null, 'Failed to create a response for ${args['command']}'); - return response; + return response!; } @override @@ -1243,9 +1243,9 @@ class FakeVmService extends Fake implements vms.VmService { @override Future getVMTimeline({int? timeOriginMicros, int? timeExtentMicros}) async { connectionLog.add('getVMTimeline $timeOriginMicros $timeExtentMicros'); - final vms.Timeline timeline = timelineResponses[timeOriginMicros ?? 1]!; + final vms.Timeline? timeline = timelineResponses[timeOriginMicros ?? 1]; assert(timeline != null, 'Missing entry in timelineResponses[$timeOriginMicros]'); - return timeline; + return timeline!; } @override