writeState method

void writeState(
  1. BuildContext context,
  2. dynamic data,
  3. {Object? identifier}
)

Write the given data into this page storage bucket using the specified identifier or an identifier computed from the given context. The computed identifier is based on the PageStorageKeys found in the path from context to the PageStorage widget that owns this page storage bucket.

If an explicit identifier is not provided and no PageStorageKeys are found, then the data is not saved.

Implementation

void writeState(BuildContext context, dynamic data, { Object? identifier }) {
  _storage ??= <Object, dynamic>{};
  if (identifier != null) {
    _storage![identifier] = data;
  } else {
    final _StorageEntryIdentifier contextIdentifier = _computeIdentifier(context);
    if (contextIdentifier.isNotEmpty) {
      _storage![contextIdentifier] = data;
    }
  }
}