Write the given data into this page storage bucket using an identifier computed from the given context. The identifier is based on the keys found in the path from context to the root of the widget tree for this page. Keys are collected until the widget tree's root is reached or a GlobalKey is found.
An explicit identifier can be used in cases where the list of keys is not stable. For example if the path concludes with a GlobalKey that's created by a stateful widget, if the stateful widget is recreated when it's exposed by pop, then its storage identifier will change.
Source
void writeState(BuildContext context, dynamic data, { Object identifier }) { _storage ??= <Object, dynamic>{}; _storage[identifier ?? _computeStorageIdentifier(context)] = data; }