Hello Guys, I hope you are doing well!
I got a question, it's how to use switch case on a class? (Here the 'state' is the main class, and other classes are inherited from state.)
like for example, I tried to replace this:
if(state is LoadingPage) {return LoadingPage;}
else if {state is SuccessPage) {return SuccessPage;}
else if {state is FailPage) {return FailPage;}
to this:
switch (state){
case LoadingPage: {return LoadingPage;}
case SuccessPage: {return SuccessPage;}
case FailPage: {return FailPage;}
}
It didn't work, what worked for me is making the state as a string, like this:
switch (state.toString()){
case 'LoadingPage': {return LoadingPage;}
case 'SuccessPage': {return SuccessPage;}
case 'FailPage': {return FailPage;}
}
It works though, but it's a short time solution, like if I had to edit something, it gonna be so hard to change everything (since it's a string)..