Class FlutterEngineCache

java.lang.Object
io.flutter.embedding.engine.FlutterEngineCache

public class FlutterEngineCache extends Object
Static singleton cache that holds FlutterEngine instances identified by Strings.

The ID of a given FlutterEngine can be whatever String is desired.

FlutterEngineCache is useful for storing pre-warmed FlutterEngine instances. FlutterActivity and FlutterFragment use the FlutterEngineCache singleton internally when instructed to use a cached FlutterEngine based on a given ID. See FlutterActivity.CachedEngineIntentBuilder and FlutterFragment.withCachedEngine(String) for related APIs.

  • Method Details

    • getInstance

      @NonNull public static FlutterEngineCache getInstance()
      Returns the static singleton instance of FlutterEngineCache.

      Creates a new instance if one does not yet exist.

    • contains

      public boolean contains(@NonNull String engineId)
      Returns true if a FlutterEngine in this cache is associated with the given engineId.
    • get

      @Nullable public FlutterEngine get(@NonNull String engineId)
      Returns the FlutterEngine in this cache that is associated with the given engineId, or null is no such FlutterEngine exists.
    • put

      public void put(@NonNull String engineId, @Nullable FlutterEngine engine)
      Places the given FlutterEngine in this cache and associates it with the given engineId.

      If a FlutterEngine already exists in this cache for the given engineId, that FlutterEngine is removed from this cache.

    • remove

      public void remove(@NonNull String engineId)
      Removes any FlutterEngine that is currently in the cache that is identified by the given engineId.
    • clear

      public void clear()
      Removes all FlutterEngine's that are currently in the cache.