start method
Implementation
void start({List<TextSpan>? text}) async {
_finished = false;
if (text != null) {
textSpanList = text;
}
// Clean the stream to prevent textStyle from changing before the text
_textSpanController.add([const TextSpan()]);
for (var span in textSpanList) {
if (_textSpanController.isClosed) return;
for (int i = 0; i < (span.text?.length ?? 0); i++) {
await Future.delayed(Duration(milliseconds: widget.speed));
if (_textSpanController.isClosed || _finished) return;
_textSpanController.add(
[
...textSpanList.sublist(0, textSpanList.indexOf(span)),
TextSpan(
text: span.text?.substring(0, i + 1),
style: span.style,
),
],
);
}
}
_finished = true;
widget.onFinish?.call();
}