createElement method

  1. @override
InheritedElement createElement()
override

Inflates this configuration to a concrete instance.

A given widget can be included in the tree zero or more times. In particular a given widget can be placed in the tree multiple times. Each time a widget is placed in the tree, it is inflated into an Element, which means a widget that is incorporated into the tree multiple times will be inflated multiple times.

Implementation

@override
InheritedElement createElement() {
  //
  final element = InheritedElement(this);
  state._inheritedElement = element;
  // Associate any dependencies widgets to this InheritedWidget
  // toList(growable: false) prevent concurrent error
  for (final context in state._dependencies.toList(growable: false)) {
    context.dependOnInheritedElement(element);
    state._dependencies.remove(context);
  }
  return element;
}