Package io.flutter.embedding.engine
Class FlutterEngineCache
- java.lang.Object
-
- io.flutter.embedding.engine.FlutterEngineCache
-
public class FlutterEngineCache extends Object
Static singleton cache that holdsFlutterEngineinstances identified byStrings.The ID of a given
FlutterEnginecan be whateverStringis desired.FlutterEngineCacheis useful for storing pre-warmedFlutterEngineinstances.FlutterActivityandFlutterFragmentuse theFlutterEngineCachesingleton internally when instructed to use a cachedFlutterEnginebased on a given ID. SeeFlutterActivity.CachedEngineIntentBuilderandFlutterFragment.withCachedEngine(String)for related APIs.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Removes allFlutterEngine's that are currently in the cache.booleancontains(String engineId)FlutterEngineget(String engineId)Returns theFlutterEnginein this cache that is associated with the givenengineId, ornullis no suchFlutterEngineexists.static FlutterEngineCachegetInstance()Returns the static singleton instance ofFlutterEngineCache.voidput(String engineId, FlutterEngine engine)Places the givenFlutterEnginein this cache and associates it with the givenengineId.voidremove(String engineId)Removes anyFlutterEnginethat is currently in the cache that is identified by the givenengineId.
-
-
-
Method Detail
-
getInstance
@NonNull public static FlutterEngineCache getInstance()
Returns the static singleton instance ofFlutterEngineCache.Creates a new instance if one does not yet exist.
-
contains
public boolean contains(@NonNull String engineId)
-
get
@Nullable public FlutterEngine get(@NonNull String engineId)
Returns theFlutterEnginein this cache that is associated with the givenengineId, ornullis no suchFlutterEngineexists.
-
put
public void put(@NonNull String engineId, @Nullable FlutterEngine engine)Places the givenFlutterEnginein this cache and associates it with the givenengineId.If a
FlutterEnginealready exists in this cache for the givenengineId, thatFlutterEngineis removed from this cache.
-
remove
public void remove(@NonNull String engineId)Removes anyFlutterEnginethat is currently in the cache that is identified by the givenengineId.
-
clear
public void clear()
Removes allFlutterEngine's that are currently in the cache.
-
-