add method

Future<void> add(
  1. String entry
)

Records entry, skipping blank lines and consecutive duplicates, then persists the (trimmed-to-cap) history. IO failures are swallowed so the interactive session is never interrupted by a disk error.

Implementation

Future<void> add(String entry) async {
  if (entry.trim().isEmpty) return;
  if (_entries.isNotEmpty && _entries.last == entry) return;
  _entries.add(entry);
  if (_entries.length > maxEntries) {
    _entries.removeRange(0, _entries.length - maxEntries);
  }
  await _persist();
}