Skip to main content

avoid-implicitly-nullable-extension-types

added in: 1.22.0
🛠
Dart 3.3+
Pro+
preset: recommended

Warns when an extension type declaration does not have the implements clause.

Not adding the implements clause (when applicable) implicitly makes the extension type nullable even when the representation type is not.

Example

❌ Bad:

// LINT: Avoid implicitly nullable extension types. Try making it implement the representation type.
extension type ET1(String s) {}

extension type ET3(String? s) {}

✅ Good:

extension type ET1(String s) implements String {} // Correct, implements String

extension type ET3(String? s) {}

Additional Resources