Last active
June 21, 2019 17:51
-
-
Save HenriBeck/98b544be833b3703714cfc9f8a4d9521 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class State {} | |
class StateA implements State { | |
StateA({this.name = "Hello"}); | |
final String name; | |
} | |
class StateB implements State {} | |
class StateHandlerNotWorking { | |
StateHandlerNotWorking({this.state}); | |
final State state; | |
void update() { | |
if (state is StateA) { | |
print(state.name); | |
} | |
} | |
} | |
class StateHandlerWorking { | |
StateHandlerWorking({this.state}); | |
final State state; | |
void update() { | |
final state = this.state; | |
if (state is StateA) { | |
print(state.name); | |
} | |
} | |
} | |
void main() {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment