Skip to content

Commit

Permalink
[google_maps_flutter] Fix memory alarm and map initialization issue
Browse files Browse the repository at this point in the history
When using a google map's addListener(), do not call the Javascript object directly.
This extremely increases memory usage.

Do:
 map.addListener('bounds_changed', (event) => { BoundChanged.postMessage('') });
Do not:
 map.addListener('bounds_changed', BoundChanged.postMessage);
  • Loading branch information
seungsoo47 committed Nov 8, 2024
1 parent d5f304e commit 4c90176
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ class GoogleMapsController {
final String options = _createOptions();
final String command = '''
map = new google.maps.Map(document.getElementById('map'), $options);
map.addListener('bounds_changed', BoundChanged.postMessage);
map.addListener('idle', Idle.postMessage);
map.addListener('click', (event) => Click.postMessage(JSON.stringify(event)));
map.addListener('tilesloaded', Tilesloaded.postMessage);
map.addListener('bounds_changed', (event) => { BoundChanged.postMessage('') });
map.addListener('idle', (event) => { Idle.postMessage('') });
map.addListener('click', (event) => { Click.postMessage(JSON.stringify(event)) });
map.addListener('tilesloaded', (evnet) => { Tilesloaded.postMessage('') });
let longPressTimeout;
map.addListener('mousedown', (e) => {
Expand Down

0 comments on commit 4c90176

Please sign in to comment.