Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick upstream#706 (Fixing memory leaks) #72

Merged
merged 4 commits into from
May 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/src/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ class MaplibreMapController extends ChangeNotifier {
}

final OnStyleLoadedCallback? onStyleLoadedCallback;

final OnMapClickCallback? onMapClick;
final OnMapLongClickCallback? onMapLongClick;

Expand Down Expand Up @@ -967,4 +966,10 @@ class MaplibreMapController extends ChangeNotifier {
Future<double> getMetersPerPixelAtLatitude(double latitude) async {
return _mapboxGlPlatform.getMetersPerPixelAtLatitude(latitude);
}

@override
void dispose() {
super.dispose();
_mapboxGlPlatform.dispose();
}
}
9 changes: 9 additions & 0 deletions lib/src/mapbox_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,15 @@ class _MaplibreMapState extends State<MaplibreMap> {
_mapboxMapOptions = _MapboxMapOptions.fromWidget(widget);
}

@override
void dispose() async {
super.dispose();
if (_controller.isCompleted) {
final controller = await _controller.future;
controller.dispose();
}
}

@override
void didUpdateWidget(MaplibreMap oldWidget) {
super.didUpdateWidget(oldWidget);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,6 @@ abstract class MapLibreGlPlatform {
{String? belowLayerId}) async {
throw UnimplementedError('addFillLayer() has not been implemented.');
}

void dispose() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -794,4 +794,10 @@ class MethodChannelMaplibreGl extends MapLibreGlPlatform {
.map((key, value) => MapEntry<String, String>(key, jsonEncode(value)))
});
}

@override
void dispose() {
super.dispose();
_channel.setMethodCallHandler(null);
}
}