Skip to main content

avoid-unnecessary-type-assertions

added in: 4.7.0
warning

Warns about unnecessary usage of is and whereType operators.

Example

Example 1 Check is same type

class Example {
final myList = <int>[1, 2, 3];

void main() {
final result = myList is List<int>; // LINT
myList.whereType<int>();
}
}

Example 2 whereType method

main(){
['1', '2'].whereType<String?>(); // LINT
}