Skip to content

Current core packages don't work with pub on Dart 2.12 and sound null safety #44031

@mit-mit

Description

@mit-mit

The current published core packages don't work with sound null safety in Dart 2.12:

  1. They use upper constraints like <2.12.0 which causes confusing pub warnings
  2. They use lower constraints like >=2.10.0-78, which pub interprets as not opted into null safety

Repro steps:

  1. Update to latest Dart/Flutter master SDK

  2. dart create repro

  3. cd repro

  4. Update pubspec.yaml to have SDK constraint: sdk: '>=2.12.0-0.0 <3.0.0'

  5. Update pubspec.yaml to not have a dependency on pedantic

  6. dart pub get

  7. dart --sound-null-safety run => Runs as expected

  8. Edit pubspec.yaml and add a dependency:

    dependencies:
      collection: ^1.15.0-nullsafety
    
  9. dart pub get

Issue 1: Upper bound warning

pub get prints:

Resolving dependencies... (1.1s)
Overriding the upper bound Dart SDK constraint to <=2.12.0-3.0.dev for the following packages:

collection

To disable this you can set the PUB_ALLOW_PRERELEASE_SDK system environment variable to `false`, or you can silence this message by setting it to `quiet`.
> collection 1.15.0-nullsafety.4 (was 1.14.13)

issue 2: Sound null safety is disabled:

pub get prints:

The package resolution is not fully migrated to null-safety.

package:collection is not opted into null safety in its pubspec.yaml:
  ╷
8 │   sdk: '>=2.10.0-78 <2.12.0'
  │        ^^^^^^^^^^^^^^^^^^^^^
  ╵

Either downgrade your sdk constraint, or invoke dart/flutter with
`--no-sound-null-safety`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NNBDIssues related to NNBD ReleaseP1A high priority bug; for example, a single project is unusable or has many test failuresarea-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.type-taskA well-defined stand-alone task

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions