Skip to content

Any UI update on google_maps_flutter example project gives error "The getter 'bearing' was called on null" #24308

@timtraversy

Description

@timtraversy

img_0388
img_0389

This error is in the example code for the google_maps_flutter plugin, in the map_ui file. Almost all of the buttons on this page present the error "The getter 'bearing' was called on null". This is because the building method tries to access the bearing property of the _position variable, but this is set to null by the code at line 59:

https://github.com/flutter/plugins/blob/d451cac0867a9fb8db055dde1785ea599d68db7c/packages/google_maps_flutter/example/lib/map_ui.dart#L57-L61

It seems mapController.cameraPosition is being set to null at some point after the GoogleMapOptions are updated. This error can be fixed by setting _position equal to mapController.options.cameraPosition instead, since this is not null when this function runs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: crashStack traces logged to the consolep: mapsGoogle Maps pluginpackageflutter/packages repository. See also p: labels.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions