Problem implementing AutomaticKeepAliveClientMixin / IndexedStack, cant save the map state

I am using OpensteetMap on one page and when the search button is hit, it goes to another page where I search for an address, and come back but the map reloads. I want to keep its state. My problem is I am already implementing an async method that will setState of a textfield after it comes back from the searchpage.

The main screen holds the map and a text field which takes me to another page to search for locations.

class MainScreen extends StatefulWidget {
    // const MainScreen({Key key}) : super(key: key);
    const String idScreen = "mainScreen";

    _MainScreenState createState() => _MainScreenState();

class _MainScreenState extends State < MainScreen >
    with AutomaticKeepAliveClientMixin < MainScreen > {
        bool get wantKeepAlive => true;

        String _dropOff = 'Choose Drof off';

        void updateInformation(String information) {
            setState(() => _dropOff = information);

        void moveToSearchScreen() async {
            //to get data back from second screen
            final dropOff = await Navigator.push(
                    fullscreenDialog: true, builder: (context) => SearchScreen()),

        void initState() {
            osmController = MapController(
                initMapWithUserPosition: false,
                initPosition: GeoPoint(latitude: 28.3949, longitude: 84.1240),

            Future.delayed(Duration(seconds: 10), () async {
                await osmController.zoom(8);
                await osmController.rotateMapCamera(45.0);
                await osmController.currentLocation();
                await osmController.rotateMapCamera(120);



Widget build(BuildContext context) {;
            onTap: () {

            ///some code
                _dropOff, //the text i get from the search page
                style: TextStyle(fontSize: 12.0),
                maxLines: 1,



The second page SearchPage simply sends the search back

    onTap: () {
        Navigator.pop( //send back data
            context, dropOffTextEditingController.text);
    child: Icon(Icons.arrow_back)),

I am not sure why I can’t save the state of the map? Even if I remove setState(() => _dropOff = information); The map will always reload
There are other options like indexedStack but I am not sure how to implement it ? All examples are with bottom Navigation bar . Is it possible to save the state any other way by keys ?

Please use state management to keep state between screens, you can use Provider for this and save the lattitude and longitude information.

Try following this guide Simple app state management - Flutter
If you face any issues, feel free to ask here.