createChildContext method
BuildContext
createChildContext({
- bool copyOldProperties = true,
- bool copyOldElement = false,
- bool setChild = true,
- BuildContext? target,
Implementation
BuildContext createChildContext(
{bool copyOldProperties = true,
bool copyOldElement = false,
bool setChild = true,
BuildContext? target}) {
final childContext = BuildContext.fromParent(this, callbacks: callbacks);
// allow overriding child. Needed for html_element_constructor
final child = target ?? this.child;
// try to preserve child context
if (child?.child != null && copyOldProperties) {
childContext.child = child?.child;
}
if (copyOldProperties) {
childContext.widget = child?.widget;
childContext.widgetState = child?.widgetState;
childContext.domChildren = child?.domChildren;
}
if (copyOldElement) {
childContext.element = child?.element;
}
if (setChild) {
if (target == null) {
this.child = childContext;
}
}
return childContext;
}