RenderBox updateLatticeChild()

in dashboard/lib/widgets/lattice.dart [208:265]


  RenderBox updateLatticeChild(_Coordinate coordinate, LatticeCell cell, RenderBox oldChild) {
    Widget newWidget;
    Element newElement;
    owner.buildScope(this, () {
      try {
        newWidget = cell.builder(this);
        debugWidgetBuilderValue(widget, newWidget);
      } catch (exception, stack) {
        newWidget = ErrorWidget.builder(
          _debugReportException(FlutterErrorDetails(
            context: ErrorDescription('building cell $coordinate for $widget'),
            exception: exception,
            stack: stack,
            library: 'Flutter Dashboard',
            informationCollector: () sync* {
              yield DiagnosticsDebugCreator(DebugCreator(this));
            },
          )),
        );
      }
      Element oldElement;
      if (newWidget.key != null) {
        oldElement = _oldChildrenByKey[newWidget.key];
        if (oldElement != null) {
          _oldChildrenByKey[newWidget.key] = null; // null indicates it exists but is not in the grid
          _oldChildrenByCoordinate.remove(oldElement.slot as _Coordinate);
        }
      } else {
        oldElement = _oldChildrenByCoordinate[coordinate];
        if (oldElement != null && oldElement.widget.key != null) {
          oldElement = null;
        }
        _oldChildrenByCoordinate.remove(coordinate);
      }
      try {
        newElement = updateChild(oldElement, newWidget, coordinate);
      } catch (e, stack) {
        newWidget = ErrorWidget.builder(
          _debugReportException(FlutterErrorDetails(
            context: ErrorDescription('building widget $newWidget at cell $coordinate for $widget'),
            exception: e,
            stack: stack,
            library: 'Flutter Dashboard',
            informationCollector: () sync* {
              yield DiagnosticsDebugCreator(DebugCreator(this));
            },
          )),
        );
        newElement = updateChild(null, newWidget, slot);
      }
    });
    assert(newElement.slot == coordinate);
    if (newWidget.key != null) {
      _newChildrenByKey[newWidget.key] = newElement;
    }
    _newChildrenByCoordinate[coordinate] = newElement;
    return newElement.renderObject;
  }