down method
Moves to the next (newer) matching entry, returning the line to show. Past
the most recent match it restores the stashed in-progress line. Returns
null when already on the fresh line.
Implementation
String? down() {
final entries = _history.entries;
if (_index >= entries.length) return null;
final active = _searchPrefix ?? '';
for (var i = _index + 1; i < entries.length; i++) {
if (entries[i].startsWith(active)) {
_index = i;
return entries[i];
}
}
_index = entries.length;
return _stash;
}