Select to view content in your preferred language

ArcGISMapView controller disposal

141
1
01-29-2026 02:33 AM
viktorviktor2342
New Contributor

Hi,

In my app I need to interact with the feature tables both when the actual map is visible in the app and when it is not. My approach has been to use the ArcGISMapViewController inside a provider so that other services can perform these geometrical modifications at any given time, independently of whether the map is actually rendered to the screen or not.

However, this causes problems, because in the ArcGIS SDK for Flutter the ArcGISMapView calls the dispose method on the controller. I don't want the UI component to own the controller, I want the provider to own it. When using for example text fields I manually have to dispose the controller, which gives me better control and flexibility, and I would like the same for this controller.

Does anyone have any suggestions on what I should do here, and if not, can we somehow add this functionality to the SDK?

0 Kudos
1 Reply
JenMerritt
Esri Contributor

Hi, thanks for your comments and thoughts. This is an interesting area that we've discussed a lot in the team, and especially early on when working on our first iteration of the map and scene views in Flutter.

There were pros and cons of making the ArcGISMapViewController be reusable in the way you describe. There are certain properties and capabilities on the controller that we definitely agree would be useful to maintain in some kind of state management - such as Provider as you describe. And we definitely understand how that pattern emerges naturally when comparing with some other widgets in Flutter, like a TextEditingController per your example. But there are other complexities around the ArcGISMapView/ArcGISSceneView that are so tightly coupled to the widget itself, such as management of drawing and gestures that separation wasn't all that straightforward.

We decided to go with the pattern we have initially but we are definitely keen to hear from our users - so your feedback is useful. I encourage anyone else to contribute to this post as well. We don't rule out anything in terms of adding support in the future, or providing something to help meet this requirement.

One thing we looked at ourselves when testing some of these different scenarios was to have a "saveController" method (or the like) in the Provider at app level, that captures any of the properties you are looking to carry over. This could be the last known viewpoint for example. Ultimately you have to set those values to a new controller that you can then pass to a new instance of the ArcGISMapView. It could be that we consider exposing some kind of function that would handle this for you, some kind of copy or save function for example.

You mention performing geometrical modifications at any given time - I'm curious if you're able to give any more info about the properties or method calls you're looking to re-use in the controller? This might help us provide additional thoughts and/or understand more about how we could look to support your workflows. Feel free to message me directly with more details, if preferred.

Thanks!

0 Kudos