Skip to main content

avoid-bottom-type-in-records

added in: 1.5.0
Dart 3.0+
Pro+

Warns when a record type declaration contains fields with void, Never or Null.

Presence of these types inside a record is most likely a bug.

Example

❌ Bad:

// LINT: Avoid the 'void' type inside records. Try using a different type.
typedef NullableRecord = ({String str, void hello});

// LINT: Avoid the 'Null' type inside records. Try using a different type.
(Null, int) nullable() => (null, 1);

// LINT: Avoid the 'Never' type inside records. Try using a different type.
(void hello, Never never) function() => (null, null);

✅ Good:

typedef NullableRecord = ({String str, Future<void> hello});

(int?, int) nullable() => (null, 1);

(String, int) correct() => ('str', 1);

Additional Resources