tick method

  1. @override
void tick()
override

Implementation

@override
void tick() {
  const train = '''
    ____
 ____|_  |___
|  _     _  |==o
'-(_)---(_)-'
''';

  final lines = train.trim().split('\n');
  final padded = lines.map((line) => (' ' * _position) + line).join('\n');

  write(padded);

  _position += _direction;

  if (_position >= _width) {
    _direction = -1;
  } else if (_position <= 0) {
    _position = 0;
    _direction = 1;
  }
}