Home > OS >  if else statement inside if else ternary statement in dart
if else statement inside if else ternary statement in dart

Time:09-23

I have a case where i need to specify

if (_amplifyConifured) {
  if (_isUserIsLoggedIn) {
    return DashboardScreen.routeName;
  } else {
    return LoginScreen.routeName;
  }
} else {
  LoadingScreen.routeName;
}


Tried this:

 _amplifyConfigured ? 
          _isUserIsLoggedIn ? DashboardScreen.routeName : LoginScreen.routeName :
          LoginScreen.routeName : LoadingScreen.routeName

But it's not throwing error

Pls help

CodePudding user response:

Lets try, you used one statement more

_amplifyConfigured ? 
          _isUserIsLoggedIn ? DashboardScreen.routeName : LoginScreen.routeName : LoadingScreen.routeName

CodePudding user response:

_amplifyConifured?
  _isUserIsLoggedIn? 
     DashboardScreen.routeName:  
      LoginScreen.routeName:
LoadingScreen.routeName;
  • Related