dart-lint icon indicating copy to clipboard operation
dart-lint copied to clipboard

Lint rule for missing yield statement

Open r-shahpasand opened this issue 4 years ago • 2 comments

In my bloc I have following code:

  @override
  Stream<VerificationState> mapEventToState(VerificationEvent event) async* {
    yield* event.when(
      loginRetry: (phoneNumber) => _loginRetry( phoneNumber ),
      verify: (phoneNumber, code) => _verify(phoneNumber, code),
    );
  }

If I forget to add yield*, lint does not warn me. How can I be warned for such a mistake?

r-shahpasand avatar Dec 10 '20 12:12 r-shahpasand

static analysis can't help here. A async* function without yield/yield* is fine, returning a Stream without elements. In many cases that's exactly what you want.

passsy avatar Dec 10 '20 12:12 passsy

Then can't I add a custom rule that warn me about this?

r-shahpasand avatar Dec 10 '20 13:12 r-shahpasand