showSpinner function
dynamic Function()
showSpinner()
Implementation
Function() showSpinner() {
const chars = r'-\|/';
int i = 0;
Timer? timer; // Make timer nullable
timer = Timer.periodic(Duration(milliseconds: 100), (_) {
stdout.write('\r${chars[i++ % chars.length]} Generating...');
});
// Return a closure that cancels the timer
return () => timer?.cancel();
}