calledChangeMetrics property

bool get calledChangeMetrics

Override this method to respond to when the StatefulWidget is recreated. Called when immediately after initState. Otherwise called only if a dependency of an InheritedWidget. Called when the application's UI dimensions change. For example, when a phone is rotated. The 'didChangeMetrics' event has already been called in a previous State object that contains this Controller.

Implementation

// @override
// void didUpdateWidget(covariant StatefulWidget oldWidget) {
//   /// The framework always calls build() after calling [didUpdateWidget], which
//   /// means any calls to [setState] in [didUpdateWidget] are redundant.
//   // Optionally call super for debugPrint()
//   super.didUpdateWidget(oldWidget);
// }

/// Called when immediately after [initState].
/// Otherwise called only if a dependency of an [InheritedWidget].
// @override
// void didChangeDependencies() {
//   // Optionally call super for debugPrint()
//   super.didChangeDependencies();
// }

/// Called when the application's UI dimensions change.
/// For example, when a phone is rotated.
// @override
// void didChangeMetrics() {
//   /// Use getter [calledChangeMetrics] to only run this once.
//   /// You sharing controllers with multiple Stat objects is common.
//   // Optionally call super for debugPrint()
//   super.didChangeMetrics();
// }

/// The 'didChangeMetrics' event has already been called in a previous State object
/// that contains this Controller.
bool get calledChangeMetrics {
  bool change = false;
  final list = _stateSet.toList(growable: false);
  for (final State state in list) {
    // You're at the current State object
    if (state == this.state) {
      change = _didCallChange;
      _didCallChange = false;
      break;
    }
    if (!_didCallChange && (state as StateX).controllerList.contains(this)) {
      _didCallChange = true;
      break;
    }
  }
  return change;
}