public class FlutterEngineCache extends Object
FlutterEngine
instances identified by String
s.
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.
Modifier and Type | Method and Description |
---|---|
boolean |
contains(String engineId)
|
FlutterEngine |
get(String engineId)
Returns the
FlutterEngine in this cache that is associated with the given engineId , or null is no such FlutterEngine exists. |
static FlutterEngineCache |
getInstance()
Returns the static singleton instance of
FlutterEngineCache . |
void |
put(String engineId,
FlutterEngine engine)
Places the given
FlutterEngine in this cache and associates it with the given engineId . |
void |
remove(String engineId)
Removes any
FlutterEngine that is currently in the cache that is identified by the
given engineId . |
@NonNull public static FlutterEngineCache getInstance()
FlutterEngineCache
.
Creates a new instance if one does not yet exist.
public boolean contains(@NonNull String engineId)
@Nullable public FlutterEngine get(@NonNull String engineId)
FlutterEngine
in this cache that is associated with the given engineId
, or null
is no such FlutterEngine
exists.public void put(@NonNull String engineId, @Nullable FlutterEngine engine)
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.
public void remove(@NonNull String engineId)
FlutterEngine
that is currently in the cache that is identified by the
given engineId
.