updateProgress method

void updateProgress(
  1. double value
)

Implementation

void updateProgress(double value) {
  _progress = value.clamp(0, 100);

  // If the public chart hasn't resolved yet we keep spinner state (no message).
  if (!_chartResolved) {
    notifyListeners();
    return;
  }

  // Map numeric progress to the loadingScreen message keys so the UI can
  // display a localized message according to the current phase.
  final pct = _progress;
  String newKey;
  if (pct < 60) {
    newKey = 'content';
  } else if (pct < 88) {
    newKey = 'request';
  } else if (pct < 100) {
    newKey = 'theme';
  } else {
    newKey = 'ready';
  }

  if (newKey != _loadingMessageKey) {
    // Switch the message immediately as progress crosses each band.
    _messageChangeTimer?.cancel();
    _loadingMessageKey = newKey;
  }

  // Always notify for progress changes immediately so the bar updates.
  notifyListeners();
}