Skip to main content

prefer-correct-stream-return-type

added in: 1.7.0
🛠
Pro+

Warns when a declaration that returns a Stream has an incorrect return type.

Object, dynamic, generic type or a nullable Stream are considered incorrect and should be replaced by a Stream.

Example

❌ Bad:

// LINT
dynamic function() async* {
return ...;
}

// LINT
Object function() async* {
return ...;
}

// LINT
Stream<int>? function() async* {
return ...;
}

// LINT
T function<T>() async* {
return ...;
}

✅ Good:

Stream<dynamic> function() async* {
return ...;
}

Stream<Object> function() async* {
return ...;
}

Stream<int> function() async* {
return ...;
}

Stream<T> function<T>() async* {
return ...;
}