loadState method
Restores a state written by saveState; returns the tokens it holds. Failures throw StateFileException.
Implementation
@override
Future<int> loadState(String path) async {
_checkOpen();
_contextEpoch++;
return _queue.run(() async {
loads++;
_checkPersistence();
final failure = failNextLoadState;
if (failure != null) {
failNextLoadState = null;
throw StateFileException('scripted loadState failure', cause: failure);
}
try {
return File(path).readAsStringSync().length ~/ 4;
} catch (e) {
throw StateFileException('cannot read $path', cause: e);
}
});
}