debugFillProperties method

  1. @override
void debugFillProperties(
  1. DiagnosticPropertiesBuilder properties
)
override

Called when a dependency of this State object changes.

For example, if the previous call to build referenced an InheritedWidget that later changed, the framework would call this method to notify this object about the change.

This method is also called immediately after _initState. It is safe to call BuildContext.dependOnInheritedWidgetOfExactType from this method.

Subclasses rarely override this method because the framework always calls build after a dependency changes. Some subclasses do override this method because they need to do some expensive work (e.g., network fetches) when their dependencies change, and that work would be too expensive to do for every build.

Implementation

// @protected
// @mustCallSuper
// void didChangeDependencies() {
//   log('ViewState<${view.runtimeType}> didChangeDependencies');
// }

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
  super.debugFillProperties(properties);
  assert(() {
    properties.add(EnumProperty<_ViewStateLifecycle>(
        'lifecycle view state', _debugLifecycleState,
        defaultValue: _ViewStateLifecycle.ready));
    return true;
  }());
  properties
      .add(ObjectFlagProperty<T>('_widget', _widget, ifNull: 'no widget'));
  properties.add(ObjectFlagProperty<StatefulViewElement>('_element', _element,
      ifNull: 'not mounted'));
}