skip to Main Content

I have a function that I’ve coded separately that performs fine when selected alone. It basically uploads some details to Firestore.

When I try to have it then Navigate back to the homepage on the same click, it navigates away but no file is made. SizedBox(

          SizedBox(
            width: 200,
            height: 75,
            child: ElevatedButton(
              onPressed: () async {
                createEvent;
                Navigator.pushNamed(context, '/homePage');
              },
              style: ElevatedButton.styleFrom(
                  backgroundColor: Colors.red,
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(50))),
              child: const Text(
                  'C R E A T E   E V E N T'
              ),
            ),
          ),

2

Answers


  1. Chosen as BEST ANSWER

    So it turns out the solution to this was in editing the createEvent code itself to perform the action rather than asking the button to do it. I simply added the line

      Navigator.of(context).pushNamed('/homePage');
    

    at the bottom of its code.


  2. Edited : sorry it forget to add the then part
    do it as the folowing

        Navigator.pushNamed(context, '/homePage').then((){// do whatever u want});
    }```
                    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search