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

Fixing memory leaks #706

Merged
Merged
Show file tree
Hide file tree
Changes from 12 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
2 changes: 1 addition & 1 deletion ios/mapbox_gl.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A new Flutter plugin.
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
s.dependency 'MapboxAnnotationExtension', '~> 0.0.1-beta.1'
s.dependency 'Mapbox-iOS-SDK', '~> 6.3.0'
s.dependency 'Mapbox-iOS-SDK', '~> 6.4.0'
s.swift_version = '4.2'
s.ios.deployment_target = '9.0'
end
Expand Down
7 changes: 6 additions & 1 deletion lib/src/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ class MapboxMapController extends ChangeNotifier {
}

final OnStyleLoadedCallback? onStyleLoadedCallback;

final OnMapClickCallback? onMapClick;
final OnMapLongClickCallback? onMapLongClick;

Expand Down Expand Up @@ -854,4 +853,10 @@ class MapboxMapController 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 @@ -232,6 +232,15 @@ class _MapboxMapState extends State<MapboxMap> {
_mapboxMapOptions = _MapboxMapOptions.fromWidget(widget);
}

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

@override
void didUpdateWidget(MapboxMap oldWidget) {
super.didUpdateWidget(oldWidget);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,7 @@ abstract class MapboxGlPlatform {
throw UnimplementedError(
'getMetersPerPixelAtLatitude() has not been implemented.');
}

void dispose() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might want to convert this to be abstract

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class is abstract already

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -719,4 +719,10 @@ class MethodChannelMapboxGl extends MapboxGlPlatform {
return new Future.error(e);
}
}

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