Skip to content

DMX4001: Dart 3.13 primary constructors reported as invalid Dart #3

Description

@wildcatDownstairs

Summary

dmx 0.3.0 reports DMX4001: input is not valid Dart on files that compile with Dart 3.13. The parser does not accept primary constructors (class const Foo(...) / class Foo(...)).
Because dmx build / dmx watch parse every .dart file under the given path (not only @dmx(...) classes), a single primary constructor anywhere in lib/ makes a project-wide generate/watch run fail.

Environment

  • dmx: 0.3.0 (VS Code extension bundled CLI, also used from terminal)
  • Dart: 3.13.0
  • Flutter: 3.47.0
  • OS: macOS (Apple Silicon)

Reproduction

  1. Create a file that is valid Dart 3.13, with no @dmx annotation:
class const ZipAddressModel({
  required final String pref,
  required final String city,
  required final String town,
});
  1. Run:
dmx build lib --insert-regions
# or
dmx watch lib

Actual

error: DMX4001: input is not valid Dart at line 2, column 13

The column points at const in class const ZipAddressModel({.
The same error appears on every primary-constructor class in the tree, for example:

error: lib/core/api/api.dart: DMX4001: input is not valid Dart at line 524, column 13
error: lib/features/wallet/schemas/zip_address_model.dart: DMX4001: input is not valid Dart at line 2, column 13

dmx watch lib still prints dmx: watching 1 path(s), but those files never get a usable parse.
dart analyze on the same files reports no issues.

Expected

  • Dart 3.13 primary constructors should parse as valid input.
  • Files without @dmx(...) should not block generate/watch for annotated classes in the same tree.
  • Alternatively, build / watch should skip files they cannot (yet) parse, instead of failing the whole run.

Workaround

Point dmx at a single experimental file instead of the whole lib/ directory:

dmx build path/to/annotated_file.dart --insert-regions
dmx watch path/to/annotated_file.dart

That is not viable for a real app whose lib/ already uses primary constructors.

Notes

Related, but separate: DMX2001 requires an explicit type on fields such as final _fieldKey = GlobalKey<...>(). That is valid inferred Dart; calling out in case the parser is intentionally stricter than the language.
Happy to provide a minimal repo if useful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions