Package io.flutter.embedding.engine
Class FlutterEngineCache
- java.lang.Object
-
- io.flutter.embedding.engine.FlutterEngineCache
-
public class FlutterEngineCache extends Object
Static singleton cache that holdsFlutterEngine
instances identified byString
s.The ID of a given
FlutterEngine
can be whateverString
is desired.FlutterEngineCache
is useful for storing pre-warmedFlutterEngine
instances.FlutterActivity
andFlutterFragment
use theFlutterEngineCache
singleton internally when instructed to use a cachedFlutterEngine
based on a given ID. SeeFlutterActivity.CachedEngineIntentBuilder
andFlutterFragment.withCachedEngine(String)
for related APIs.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Removes allFlutterEngine
's that are currently in the cache.boolean
contains(String engineId)
FlutterEngine
get(String engineId)
Returns theFlutterEngine
in this cache that is associated with the givenengineId
, ornull
is no suchFlutterEngine
exists.static FlutterEngineCache
getInstance()
Returns the static singleton instance ofFlutterEngineCache
.void
put(String engineId, FlutterEngine engine)
Places the givenFlutterEngine
in this cache and associates it with the givenengineId
.void
remove(String engineId)
Removes anyFlutterEngine
that 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 theFlutterEngine
in this cache that is associated with the givenengineId
, ornull
is no suchFlutterEngine
exists.
-
put
public void put(@NonNull String engineId, @Nullable FlutterEngine engine)
Places the givenFlutterEngine
in this cache and associates it with the givenengineId
.If a
FlutterEngine
already exists in this cache for the givenengineId
, thatFlutterEngine
is removed from this cache.
-
remove
public void remove(@NonNull String engineId)
Removes anyFlutterEngine
that is currently in the cache that is identified by the givenengineId
.
-
clear
public void clear()
Removes allFlutterEngine
's that are currently in the cache.
-
-