0

Below is the sequence of pages that I have:

  • Upload Page -> User selects some options

    • Form Page -> User enters value in form and click Upload

When upload is done, the user is taken back to Upload page by using the below code.

      if (Navigator.canPop(context)) {
         Navigator.pop(context);
      }

All works fine.

My Actual Issue:

When the upload is done, I want the users to be taken to the detail page of the uploaded item. But the push does not work.

Below is the full code.

DesignsBlocProvider.of(context).addDesign(postData).then((val) {

      setState(() {
         uploading = false;
      });

      // To close the form page after upload. This works.
      if (Navigator.canPop(context)) {
         Navigator.pop(context);
      }

      // This does not work. 
      // Ideally user should be taken to DesignViewWidget page.
      Navigator.pushReplacement(
            context,
            MaterialPageRoute(builder: (context) => DesignViewWidget(design)),
      );
})
Purus
  • 5,701
  • 9
  • 50
  • 89

0 Answers0