Closed
Description
covariant
usage has caused subtle null safety bugs when the subtype is nonnull. Example:
flutter/packages/flutter_tools/lib/src/device.dart
Lines 585 to 588 in e4a80b4
flutter/packages/flutter_tools/lib/src/ios/simulators.dart
Lines 535 to 537 in e4a80b4
When null
is passed into stopApp
, but the override doesn't handle a null ApplicationPackage
it caused runtime crash:
stderr: [ +7 ms] NoSuchMethodError: The getter 'id' was called on null.
stderr: Receiver: null
stderr: Tried calling: id
Audit covariant
usage and remove where possible.
See https://dart.dev/guides/language/sound-problems#the-covariant-keyword