Skip to content

Commit dcc82e0

Browse files
ditmanEgor
authored andcommitted
[google_maps_flutter_platform_interface] Add dispose method. (flutter#2908)
This method gives the plugin writers a chance to release the resources that they've acquired throughout the operation of the plugin (think of it as an "inverse" of the "init" method).
1 parent 5a1301b commit dcc82e0

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.4
2+
3+
* Add a `dispose` method to the interface, so implementations may cleanup resources acquired on `init`.
4+
15
## 1.0.3
26

37
* Pass icon width/height if present on `fromAssetImage` BitmapDescriptors (web only)

packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/method_channel_google_maps_flutter.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
4848
return channel.invokeMethod<void>('map#waitForMap');
4949
}
5050

51+
/// Dispose of the native resources.
52+
@override
53+
void dispose({int mapId}) {
54+
// Noop!
55+
}
56+
5157
// The controller we need to broadcast the different events coming
5258
// from handleMethodCall.
5359
//

packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/platform_interface/google_maps_flutter_platform.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface {
304304
throw UnimplementedError('onLongPress() has not been implemented.');
305305
}
306306

307+
/// Dispose of whatever resources the `mapId` is holding on to.
308+
void dispose({@required int mapId}) {
309+
throw UnimplementedError('dispose() has not been implemented.');
310+
}
311+
307312
/// Returns a widget displaying the map view
308313
Widget buildView(
309314
Map<String, dynamic> creationParams,

packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: A common platform interface for the google_maps_flutter plugin.
33
homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter/google_maps_flutter_platform_interface
44
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
55
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
6-
version: 1.0.3
6+
version: 1.0.4
77

88
dependencies:
99
flutter:

0 commit comments

Comments
 (0)