Skip to main content

avoid-explicit-pattern-field-name

added in: 1.5.0
style
Dart 3.0

Warns when an object pattern has an explicit field name.

Example

❌ Bad:

const iterable = {...};

if (iterable case Set(firstOrNull: final firstOrNull)) {} // LINT
if (iterable case Set(first: final first)) {} // LINT

✅ Good:

const iterable = {...};

if (iterable case Set(:final firstOrNull)) {}
if (iterable case Set(firstOrNull: final alias)) {}

if (iterable case Set(:final first)) {}
if (iterable case Set(first: final alias)) {}