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

Skip to content

Packages with example apps opted-in for null safety fail the null safety checks #44013

Closed
@amirh

Description

@amirh

This came up in flutter/flutter#69440 (comment) where a bunch of flutter/plugins packages started failing on CI.

@zanderso and @leafpetersen pointed out that the failing packages included example apps with no Dart SDK constraints which means they are treated as opted-in for null safety.

While the flutter/plugins packages are fixed in flutter/plugins#3240 it's somewhat worrying that many other packages in the ecosystem will take a similar hit.

I counted the affected packages across pub and there are currently 725 packages with example apps that are opted-in for null safety (most likely unintentionally as null safety isn't launched yet).

698 of these packages are actually not opted-in for null safety (e.g the root pubspec.yaml isn't opted-in while example/pubspec.yaml is opted in).
For these 698 packages I believe it should be safe to assume that the sdk constraint in example/pubspec.yaml should be intersected with the sdk constraints of the root pubspec.yaml. So it's fairly easy to automate the fix.

The list of the 698 "fixable" packages is available in this sheet.

I'm happy to send PRs using dart_lsc to fix example/pubspec.yaml for as many of these 698 packages as possible.
I guess another alternative to consider would be to somehow teach the analyzer that the example app's sdk constraint cannot be wider than the package's sdk constraint.

cc @mit-mit @csells

Metadata

Metadata

Assignees

Labels

NNBDIssues related to NNBD ReleaseP1A high priority bug; for example, a single project is unusable or has many test failuresarea-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions