Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
package io.flutter.plugins.googlemaps;

import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.google.android.gms.maps.MapsInitializer;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnMapsSdkInitializedCallback;
import io.flutter.plugin.common.BinaryMessenger;

/** GoogleMaps initializer used to initialize the Google Maps SDK with preferred settings. */
final class GoogleMapInitializer
implements OnMapsSdkInitializedCallback, Messages.MapsInitializerApi {
private static final String TAG = "GoogleMapInitializer";
private final Context context;
private static Messages.Result<Messages.PlatformRendererType> initializationResult;
private boolean rendererInitialized = false;
Expand All @@ -41,6 +44,29 @@ public void initializeWithPreferredRenderer(
}
}

@Override
public void warmup(@NonNull Messages.VoidResult result) {
Log.i(TAG, "Google Maps warmup started.");
try {
// This creates a fake map view in order to trigger the SDK's
// initialization. For context, see
// https://github.com/flutter/flutter/issues/28493#issuecomment-2919150669.
MapView mv = new MapView(context);
mv.onCreate(null);
mv.onPause();
mv.onDestroy();
Comment thread
filiph marked this conversation as resolved.
Outdated
Log.i(TAG, "Maps warmup complete.");
result.success();
} catch (Exception e) {
result.error(
new Messages.FlutterError(
"Could not warm up",
e.toString(),
null));
}
}


/**
* Initializes map renderer to with preferred renderer type.
*
Expand Down
Loading