dart-lang/sdk

Asserts in initializers

Closed this issue · 5 comments

Flutter likes it, so the language team considers the experiment a success and will ship asserts in constructor initialization lists in Dart 2.0.

Work remaining to be done:

  • Support it in dart2js (#30038)
  • Support it in dartdevc (#27809)
  • Support in front-end (#30914)
  • Specify it (#30967)
  • Enable it by default and remove flag in VM (#30976)
  • Enable it by default and remove flag in analyzer (#30977)
  • Document and announce it

@munificent @kwalrath is there any more to do on the docs/announce front? If not, let's close this.

The language tour should cover asserts in initializers (and probably have more initializer coverage, in general). I've added this to dart-lang/site-www#507.

Yeah, aside from what Kathy said, I don't see any need to trumpet this feature from the heavens. It's pretty minor.

rkj commented

Any documentation? I just tried to use it, but cannot use foreach in the assert body, which makes it less usable than I would like (I wanted to verify that a map passed to the constructor doesn't have null values)

No doc that I know of. The spec changes landed here 609d26a, a72f46d.