inflateWidget method
Creates the element of newWidget and mounts it as a child of this
one at newSlot. For a widget with a GlobalKey, the element of the
key moves here instead if the widget can update it, wherever it is in
the tree or among the elements removed in the frame: with its subtree,
state and render objects, the old parent letting go of it. When that
throws, what was mounted or moved here leaves the tree again.
Implementation
@protected
Element inflateWidget(Widget newWidget, Object? newSlot) {
final key = newWidget.key;
Element? element;
try {
if (key is GlobalKey) {
element = _retake(key, newWidget);
if (element != null) {
element._activateWithParent(this, newSlot);
return updateChild(element, newWidget, newSlot)!;
}
}
return (element = newWidget.createElement())..mount(this, newSlot);
} on Object {
if (element != null && identical(element._parent, this)) {
deactivateChild(element);
}
rethrow;
}
}