Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Audit covariant usage in flutter_tool #114090

Closed
@jmagman

Description

@jmagman

covariant usage has caused subtle null safety bugs when the subtype is nonnull. Example:

Future<bool> stopApp(
covariant ApplicationPackage? app, {
String? userIdentifier,
});

Future<bool> stopApp(
ApplicationPackage app, {
String? userIdentifier,

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

https://fusion2.corp.google.com/invocations/68e930bd-fdd0-486f-9b8d-dec7798677c9/targets/%2F%2Fmobile%2Fflutter%2Ftests%2Fapp:app_basic_runner_attach_ios_test_IPHONE_11_13_0/log

Audit covariant usage and remove where possible.

See https://dart.dev/guides/language/sound-problems#the-covariant-keyword

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: tech-debtTechnical debt, code quality, testing, etc.toolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions