flutter_map Docs
Project Links💝 Support Us
v6
v6
  • flutter_map
  • 🏗️Showcase
  • 💝Supporters
  • ✏️Credits & Contributing
  • Getting Started
    • How Does It Work?
      • Raster vs Vector Tiles
    • Demonstration
    • Installation
    • Examples
    • Migrating To v6
  • Usage
    • Base Widget
    • Options
      • Interaction Options
    • Layers
    • Programmatic Control
      • Control Camera
      • Get Camera
      • Listen To Events
    • Full API Reference
  • Layers
    • Tile Layer
      • Tile Providers
      • WMS Usage
    • Marker Layer
    • Polygon Layer
    • Polyline Layer
    • Circle Layer
    • Overlay Image Layer
    • Attribution Layer
  • Tile Servers
    • Using Mapbox
    • Using Thunderforest
    • Using Stadia Maps
    • Using Bing Maps
    • Offline Mapping
    • Other Options
  • Plugins
    • Plugins List
    • Creating A Plugin
      • Creating New Tile Providers
      • Creating New Layers
Powered by GitBook

© flutter_map Authors & Maintainers

On this page
  • Usage Inside Of A FlutterMap Child
  • Usage Outside Of FlutterMap
  • Single Time
  • Listen To Changes

Was this helpful?

Export as PDF
  1. Usage
  2. Programmatic Control

Get Camera

PreviousControl CameraNextListen To Events

Last updated 9 months ago

Was this helpful?

The MapCamera object describes the map's current viewport. It does not provide methods to change it: that is the responsibility of a .

The MapCamera object also provides access to some other helpful methods that depend on it, such as pointToLatLng & latLngToPoint.

Usage Inside Of A FlutterMap Child

To get the camera from within the context of a FlutterMap widget, use MapCamera.of(context).

If this behaviour is unwanted, use Single Time instead.

If this throws a StateError, try wrapping the concerned widget in a Builder, to ensure the FlutterMap widget is parenting the BuildContext. If this has no effect, use Usage Outside Of FlutterMap instead.

Usage Outside Of FlutterMap

Single Time

Then, use the .camera getter.

Avoid using MapController.of(context).camera from within the context of FlutterMap, as it is redundant and less performant than using MapCamera.of(context) directly.

Listen To Changes

Calling this method in a build method will cause the widget to automatically rebuild when the MapCamera changes. See for more information.

To get the camera from outside the context of the FlutterMap widget, you'll need to setup a MapController first: see Control Camera > .

Listen To Events
MapController
MapCamera class - flutter_map library - Dart API
Logo
#2.-hooking-into-inherited-state
Usage Outside Of FlutterMap