Skip to content

Google map setState #1180

@al-mahi

Description

@al-mahi

Has your issue been reported?

  • I have searched the existing issues and confirm it has not been reported.
  • I give permission for members of the FlutterFlow team to access and test my project for the sole purpose of investigating this issue.

Current Behavior

Not an expert on code. found some fix of issues i faced using chat gpt

  1. Multiple google map instance will causes crash
  2. A marker on map which has been removed can cause memory leak if not checked if the

Expected Behavior

correct code:
@override
void setState(VoidCallback callback) {
if(mounted) super.setState(callback);
_model.onUpdate();
}
memory leaky code:
@override
void setState(VoidCallback callback) {
super.setState(callback);
_model.onUpdate();
}

correct code
if (!_controller.isCompleted) {
_controller.complete(controller);
}
code that will crash if multiple google map is used:
child: GoogleMap(
onMapCreated: (controller) async {
_controller.complete(controller);
await controller.setMapStyle(googleMapStyleStrings[widget.style]);
},

Steps to Reproduce

create two pages with google map
the first will work fine but second one will crash

if a marker document is removed but in map it is not update and click event will cause memory leak issue

Reproducible from Blank

  • The steps to reproduce above start from a blank project.

Bug Report Code (Required)

correct code: @OverRide void setState(VoidCallback callback) { if(mounted) super.setState(callback); _model.onUpdate(); } memory leaky code: @OverRide void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } correct code if (!_controller.isCompleted) { _controller.complete(controller); } code that will crash if multiple google map is used: child: GoogleMap( onMapCreated: (controller) async { _controller.complete(controller); await controller.setMapStyle(googleMapStyleStrings[widget.style]); },

Context

cause my app to crash

Visual documentation

None

Additional Info

correct code:
@OverRide
void setState(VoidCallback callback) {
if(mounted) super.setState(callback);
_model.onUpdate();
}
memory leaky code:
@OverRide
void setState(VoidCallback callback) {
super.setState(callback);
_model.onUpdate();
}

correct code
if (!_controller.isCompleted) {
_controller.complete(controller);
}
code that will crash if multiple google map is used:
child: GoogleMap(
onMapCreated: (controller) async {
_controller.complete(controller);
await controller.setMapStyle(googleMapStyleStrings[widget.style]);
},

Environment

- FlutterFlow version: 3.1
- Platform:ios
- Browser name and version: chrome & 114.0
- Operating system and version affected: mac os ventura

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions