public class RestorationChannel extends Object
The engine can obtain the current restoration data from the framework via this channel to store it on disk and - when the app is relaunched - provide the stored data back to the framework to recreate the original state of the app.
The channel can be configured to delay responding to the framework's request for restoration
waitForRestorationData until the engine-side has provided the data. This is
useful when the engine is pre-warmed at a point in the application's life cycle where the
restoration data is not available yet. For example, if the engine is pre-warmed as part of the
Application before an Activity is created, this flag should be set to true because Android will
only provide the restoration data to the Activity during the onCreate callback.
The current restoration data provided by the framework can be read via
|Modifier and Type||Field and Description|
Whether the channel delays responding to the framework's initial request for restoration data until
|Constructor and Description|
|Modifier and Type||Method and Description|
Clears the current restoration data.
Obtain the most current restoration data that the framework has provided.
Set the restoration data from which the framework will restore its state.
public final boolean waitForRestorationData
setRestorationDatahas been called.
If the engine never calls
setRestorationData this flag must be set to false. If set
to true, the engine must call
setRestorationData either with the actual restoration
data as argument or null if it turns out that there is no restoration data.
If the response to the framework's request for restoration data is not delayed until the
data has been set via
setRestorationData, the framework may intermittently initialize
itself to default values until the restoration data has been made available. Setting this flag
to true avoids that extra work.
public RestorationChannel(@NonNull DartExecutor dartExecutor, @NonNull boolean waitForRestorationData)
public byte getRestorationData()
public void setRestorationData(byte data)
public void clearData()
This should be called just prior to a hot restart. Otherwise, after the hot restart the state prior to the hot restart will get restored.