I need to implement simple functionality: AnimatedPositioned stripes go down with a speed _speed, and when they reach the end of the screen (after disappearing), they must immediately (with a speed 0) fly up to position _top = 0 and then start moving down again).

My script works, but sometimes with strange delays. However, I understand that I'm doing something wrong (by setting up the delay of 10000). If I set it up to a smaller value, it does not work at all.

What is the correct approach? Maybe I better need to track the disappearing Widgets from the screen?

            onPressed: () async {
              while (true) {

                await new Future.delayed(Duration(microseconds: (10000)));
                setState(() {
                  _reset_duration = 1; //this is to keep normal speed
                  _top = 2 *
                      _height *
                      (MediaQuery.of(context).size.height / 2 / _height).ceil();

                await new Future.delayed(
                    Duration(microseconds: (_speed).toInt()));
                setState(() {
                  _reset_duration = 0; //this is to reset speed
                  _top = 0;
            child: const Icon(Icons.arrow_downward),