Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to trigger a method from a route you are directing to?

So I have a map view where I route to another view. In that map route I got a method:

  void animateToUser() async {
    final pos = await _location.getLocation();
    _mapController?.animateCamera(CameraUpdate.newCameraPosition(CameraPosition(
        target: LatLng(pos.latitude!, pos.longitude!), zoom: 15)));
  }

When Im on another view I use this to go back to the screen

  onTap: () {
      Navigator.of(context).pop();
   })

However I would like to trigger this animateToUser method just after the pop method. Is this achievable?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

you can pass this callback to your new screen. so you have access to call it before Navigator.of(context).pop();.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading