didChangeTextScaleFactor method

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

Called when the platform's text scale factor changes.

Implementation

@protected
@override
@mustCallSuper
void didChangeTextScaleFactor() {
  ///
  /// This typically happens as the result of the user changing system
  /// preferences, and it should affect all of the text sizes in the
  /// application.
  ///
  /// This method exposes notifications from [Window.onTextScaleFactorChanged].
  /// See sample code below. No need to call super if you override.
  ///   @override
  ///   void didChangeTextScaleFactor() {
  ///     setState(() { _lastTextScaleFactor = ui.window.textScaleFactor; });
  ///   }

  // A triggered system event
  _hadSystemEvent = true;

  // Don't if the State object is defunct.
  if (!mounted) {
    return;
  }

  /// No 'setState()' functions are allowed to fully function at this point.
  _setStateAllowed = false;

  for (final con in controllerList) {
    con.didChangeTextScaleFactor();
  }

  _setStateAllowed = true;

  if (_setStateRequested) {
    _setStateRequested = false;
    // Only the latest State is rebuilt
    if (isEndState) {
      /// Perform a 'rebuild' if requested.
      setState(() {});
    }
  }
}