0

I have just updated to latest dart-beta version (2.11.0-213.5.beta) and upgraded my dependencies to use the null safety versions:

dev_dependencies:
  pedantic: ^1.10.0-nullsafety
  test: ^1.16.0-nullsafety

I can successfully run dart analyze . after annotating all my types correctly to work with NNBD.

Now, I cannot run my tests at all because the test command does not yet seem to accept the flag --enable-experiment=non-nullable.

I can run my package's examples with dart --enable-experiment=non-nullable example/actors_example.dart fine.

How to make the test runner use NNBD so I can run my tests?

Renato
  • 12,940
  • 3
  • 54
  • 85
  • The latest dev which is dart 1.12 supports nnbd without having to set the flag, you might want to try that (make sure also to update the sdk constraints) – Mattia Nov 07 '20 at 10:22
  • You mean, the `dart-dev` channel instead of `dart-beta`, right? – Renato Nov 07 '20 at 10:30
  • I can find `dart-beta` in brew, but not `dart-dev`. I guess they are not publishing dev releases on Brew?! – Renato Nov 07 '20 at 10:35
  • I'm not sure about Brew but you can find it here https://dart.dev/tools/sdk/archive – Mattia Nov 07 '20 at 14:02

1 Answers1

0

Things are moving fast in the Dart world. Looks like the test package with NNBD is not working anymore in the beta channel, it only works properly in the newest and hottest dev channel.

After manually downloading the dev channel SDK (which doesn't seem to be published on Brew), and upgrading my dependencies again, I was able to get my package ready for NNBD and tests running ok!

Here's what my SDK version constraints look like as of Nov 2020:

environment:
  sdk: ">=2.12.0-13.0.dev <2.13.0"

When I run dart --version I see this:

Dart SDK version: 2.12.0-13.0.dev (dev) (Mon Nov 2 15:57:37 2020 -0800) on "macos_x64"

Upgraded dependencies:

dev_dependencies:
  pedantic: ^1.10.0-nullsafety.3
  test: ^1.16.0-nullsafety.9

Now, because Dart 2.12 unifies all Dart tools into the dart command, I run my tests with:

dart test

Instead of the old pub run test. All great and working again.

Can't wait for NNBD to come to stable Dart!!

Renato
  • 12,940
  • 3
  • 54
  • 85