Meta : Add lint for async intialization method #59196
Labels
devexp-linter
Issues with the analyzer's support for the linter package
legacy-area-analyzer
Use area-devexp instead.
Uh oh!
There was an error while loading. Please reload this page.
Usually, when you need to construct a class in an asynchronous way, you use a static method:
This is not ideal, because :
final a = await A();
An alternative would be to have an init method :
Alternatively, the
init
method could be returning a newly fully initialized instance (This can be helpful in some specific implementations where the initialized instance MUST be a newly created one) :The problem with having an initialization method is that if you forget to call it, you get a runtime error.
It would be great if we could annotate the init method with something like
@initMethod
, and whenever you call the constructor / factory constructor, you get a warning reminding you to call the init method.The text was updated successfully, but these errors were encountered: