How to get bounds of visible map with Flutter Google Map plugin

In this Google Flutter code snippet example, we are going to learn How to get bounds of visible map with flutter google maps plugin.

You can copy and adopt this source code example to your flutter project easily without issues.

Add this code to your pubspec.yaml file

permission_handler: ^3.0.1
google_maps_flutter: ^0.5.19

Create a get_visible_bounds.dart file (use any name of your choice) and add this code:

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

class GetVisibleBounds extends StatefulWidget {
  _GetVisibleBoundsState createState() => _GetVisibleBoundsState();

class _GetVisibleBoundsState extends State<GetVisibleBounds> {
  Completer<GoogleMapController> _controller = Completer();
  GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();

  static const LatLng _center = const LatLng(45.521563, -122.677433);

  LatLng _lastMapPosition = _center;

  void _onCameraMove(CameraPosition position) {
    _lastMapPosition =;

  void _onMapCreated(GoogleMapController controller) async  {
    LatLngBounds latLngBounds = await controller.getVisibleRegion();
    _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text("NorthEast: ${latLngBounds.northeast.latitude}, ${latLngBounds.northeast.longitude}. SouthWest: ${latLngBounds.southwest.latitude}, ${latLngBounds.southwest.longitude}")));

  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        key: _scaffoldKey,
        appBar: AppBar(
          title: Text('Visible Bounds of Map'),
        body: Stack(
          children: <Widget>[
              onMapCreated: _onMapCreated,
              myLocationEnabled: true,
              initialCameraPosition: CameraPosition(
                target: _center,
                zoom: 11.0,
              onCameraMove: _onCameraMove,
            /* Padding(
              padding: const EdgeInsets.all(16.0),
              child: Align(
                alignment: Alignment.topRight,
                child: Column(
                  children: <Widget> [
                      onPressed: _onGetBoundsButtonPressed,
                      materialTapTargetSize: MaterialTapTargetSize.padded,
                      child: const Icon(, size: 36.0),
            ), */

In your main.dart file (main entry point of the app), add this:

import 'package:inducesmile/get_visible_bounds.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return new MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Code Snippets',
      theme: new ThemeData(primarySwatch:,
      home: new GetVisibleBounds(),

If you have any questions or suggestions kindly use the comment box or you can contact us directly through our contact page below.

Add a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

50% Discounts On Projects

Do you have a custom project with a clear requirements, we are currently giving a 50% discount on all projects.

We will work with you to ensure we deliver what you need.

If you have questions or want to chat with us, you can reach us on Skype (henry.tochi)

Languages and technologies we use - Java, Kotlin, Laravel, Vue, React, Flutter, Swift and more.