didUpdateRestorationId method

  1. @protected
void didUpdateRestorationId()

Must be called when the value returned by restorationId changes.

This method is automatically called from didUpdateWidget. Therefore, manually invoking this method may be omitted when the change in restorationId was caused by an updated widget.


void didUpdateRestorationId() {
  // There's nothing to do if:
  //  - We don't have a parent to claim a bucket from.
  //  - Our current bucket already uses the provided restoration ID.
  //  - There's a restore pending, which means that didChangeDependencies
  //    will be called and we handle the rename there.
  if (_currentParent == null || _bucket?.restorationId == restorationId || restorePending) {

  final RestorationBucket? oldBucket = _bucket;
  final bool didReplaceBucket = _updateBucketIfNecessary(parent: _currentParent, restorePending: false);
  if (didReplaceBucket) {
    assert(oldBucket != _bucket);
    assert(_bucket == null || oldBucket == null);