start method

void start([
  1. String? message
])

Start the spinner with an optional message

Implementation

void start([String? message]) {
  if (_running) return;

  if (message != null) {
    _message = message;
  }

  _running = true;
  _currentFrame = 0;

  // Hide cursor
  stdout.write('\x1B[?25l');

  _timer = Timer.periodic(Duration(milliseconds: 80), (_) {
    _clearPreviousLine();
    final frame = _spinnerFrames[_currentFrame];
    stdout.write('\r\x1B[36m$frame\x1B[0m $_message');
    _previousLine = '\r\x1B[36m$frame\x1B[0m $_message';
    _currentFrame = (_currentFrame + 1) % _spinnerFrames.length;
  });
}