Use moveUp, concatenate your string (str) and then blank the remaining line.
str
static String replacePreviousLine(str) => moveUp(1) + str + blankRemaining();