Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add'when' conditional statement #1963

Closed
tmxdyf opened this issue Nov 5, 2021 · 1 comment
Closed

Add'when' conditional statement #1963

tmxdyf opened this issue Nov 5, 2021 · 1 comment
Labels
feature Proposed language feature that solves one or more problems state-duplicate This issue or pull request already exists

Comments

@tmxdyf
Copy link

tmxdyf commented Nov 5, 2021

Hope to add a conditional statement similar to the ‘when’ in the Kotlin language.

dart language:

  FutureOr<void> onEventHandler(
      SpeechPageEvent event, Emitter<SpeechPageState> emit) async {
    debugPrint("onEventHandler#event==$event");

    if (event is InitSpeechBlocEvent) {
      
    } else if (event is OnLongPressStartEvent) {
      
    } else if (event is OnLongPressEndEvent) {
      
    } else if (event is OnLongPressMoveUpdateEvent) {
      
    } else if (event is OnLeftLanguagePressedEvent) {
      
    } else if (event is OnRightLanguagePressedEvent) {
      
    } 
  }

Kotlin

when(event){
    is InitSpeechBlocEvent->{

    }
    is OnLongPressStartEvent->{

    }
    ...
}
@tmxdyf tmxdyf added the feature Proposed language feature that solves one or more problems label Nov 5, 2021
@lrhn
Copy link
Member

lrhn commented Nov 5, 2021

This sound like a job for pattern matching.

Also #1509, #27.

@lrhn lrhn closed this as completed Nov 5, 2021
@lrhn lrhn added the state-duplicate This issue or pull request already exists label Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Proposed language feature that solves one or more problems state-duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants