diff --git a/maplibre_gl/android/src/main/java/org/maplibre/maplibregl/GlobalMethodHandler.java b/maplibre_gl/android/src/main/java/org/maplibre/maplibregl/GlobalMethodHandler.java index a58eed0a..8817c883 100644 --- a/maplibre_gl/android/src/main/java/org/maplibre/maplibregl/GlobalMethodHandler.java +++ b/maplibre_gl/android/src/main/java/org/maplibre/maplibregl/GlobalMethodHandler.java @@ -79,8 +79,13 @@ public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) { result.success(null); break; case "setOffline": - Boolean offline = (Boolean) methodCall.argument("offline"); - ConnectivityReceiver.instance(context).setConnected(offline!=null ? !(offline) : null); + boolean offline = methodCall.argument("offline"); + ConnectivityReceiver.instance(context).setConnected(offline ? false : null); + result.success(null); + break; + case "setConnected": + boolean connected = methodCall.argument("connected"); + ConnectivityReceiver.instance(context).setConnected(connected ? true : null); result.success(null); break; case "mergeOfflineRegions": diff --git a/maplibre_gl/lib/src/global.dart b/maplibre_gl/lib/src/global.dart index c6ed4e14..87ef38db 100644 --- a/maplibre_gl/lib/src/global.dart +++ b/maplibre_gl/lib/src/global.dart @@ -19,13 +19,20 @@ Future installOfflineMapTiles(String tilesDb) async { enum DragEventType { start, drag, end } -Future setOffline(bool? offline) => _globalChannel.invokeMethod( +Future setOffline(bool offline) => _globalChannel.invokeMethod( 'setOffline', { 'offline': offline, }, ); +Future setConnected(bool connected) => _globalChannel.invokeMethod( + 'setConnected', + { + 'connected': connected, + }, +); + Future setHttpHeaders(Map headers) { return _globalChannel.invokeMethod( 'setHttpHeaders',