Skip to content

Adjust documentation of prefer_void_to_null #58908

@eernstg

Description

@eernstg

The lint prefer_void_to_null has a very concise motivation section. #58906 raised the issue that it isn't helpful to recommend that a local variable of type Null is changed such that the type is void. An extended motivation section could clarify more broadly in which situations the lint is useful.

Another part of the documentation that needs an update is at the end:

empty literals which are safe to pass into read-only locations for any type of map or list

Today, with null safety, such collection literals should have the actual type argument Never (like const <Never>[]). The type argument could also be Null, but the collection would then only be usable when the required type has a nullable type argument.

Note that a type variable is never a nullable type, which means that <Null>[] could never be passed when the required type is List<X> where X is a type variable; this seems to make <Null>[] nearly useless as a "universal empty list", so we probably don't even want to mention <Null>[] in the documentation for this lint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packagelinter-set-recommendedtype-documentationA request to add or improve documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions