didChangeMetrics method

  1. @protected
  2. @override
  3. @mustCallSuper
void didChangeMetrics()
inherited

Called when the application's dimensions change. For example, when a phone is rotated.

Implementation

@protected
@override
@mustCallSuper
void didChangeMetrics() {
  /// In general, this is not overridden often as the layout system takes care of
  /// automatically recomputing the application geometry when the application
  /// size changes
  ///
  /// This method exposes notifications from [Window.onMetricsChanged].
  /// See sample code below. No need to call super if you override.
  ///   @override
  ///   void didChangeMetrics() {
  ///     setState(() { _lastSize = ui.window.physicalSize; });
  ///   }

  /// No 'setState()' functions are allowed to fully function at this point.
  _rebuildAllowed = false;
  for (final listener in _beforeList) {
    listener.didChangeMetrics();
  }
  for (final con in _controllerList) {
    con.didChangeMetrics();
  }
  for (final listener in _afterList) {
    listener.didChangeMetrics();
  }
  _rebuildAllowed = true;
  if (_rebuildRequested || _inTester) {
    _rebuildRequested = false;

    /// Perform a 'rebuild' if requested.
    refresh();
  }
}