Package io.flutter.embedding.engine

## Class FlutterEngineCache

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

-     public class FlutterEngineCache
      extends Object

  Static singleton cache that holds `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.

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `clear()` | Removes all `FlutterEngine`'s that are currently in the cache.
    `boolean` | `contains​(String engineId)` | Returns `true` if a `FlutterEngine` in this cache is associated with the given `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`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### 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.