Navigate to next page based on a condition in flutter

Viewed 765

I created a signIn page in flutter using MongoDB, when user enters valid credentials they have to be navigated to HomePage, else they should stay in the same page. How can I achieve this logic?

when they enter valid credentials I am able to print user successful in the console, but how can I navigate to next page if it is isLogin = true?

 Future<String> signIn() async {
      final response = await http.post(
        serverReceiverPath,
        headers: {'Content-Type': 'application/json'},
      );
      if(response.body == 'Login successful'){
        isLogin = true;
      }else{
        isLogin = false;
      }
      print(response.body);
      print(isLogin);
    }
1 Answers
Related