printWithLoadingAmimation method

void printWithLoadingAmimation(
  1. String message
)

Implementation

void printWithLoadingAmimation(String message) {
  stdout.write('$message ');

  timer = Timer.periodic(Duration(milliseconds: 100), (Timer t) {
    stdout.write(animationFrames[frameIndex]);
    stdout.write('\b'); // Move the cursor back one position

    frameIndex = (frameIndex + 1) % animationFrames.length;
  });
}