stop method

void stop({
  1. bool success = true,
  2. String? finalMessage,
})

Stops the spinner animation.

Implementation

void stop({bool success = true, String? finalMessage}) {
  if (_timer == null) return;
  _timer?.cancel();
  _timer = null;
  if (stdout.hasTerminal) {
    stdout.write('\r\x1B[K'); // Clear line
    stdout.write('\x1B[?25h'); // Show cursor
    if (success) {
      stdout.writeln('\x1B[32m✔\x1B[0m ${finalMessage ?? message}');
    } else {
      stdout.writeln('\x1B[31m✘\x1B[0m ${finalMessage ?? message}');
    }
  }
}