initialize method
Load persisted requests from disk. Must be called before using the store.
Implementation
Future<void> initialize() async {
if (_initialized) return;
_initialized = true;
try {
if (await _file.exists()) {
final content = await _file.readAsString();
if (content.isNotEmpty) {
final list = jsonDecode(content) as List<dynamic>;
for (final item in list) {
_queue.add(
SerializableRequest.fromJson(item as Map<String, dynamic>),
);
}
_logger.info(
'PersistentQueueStore: restored ${_queue.length} request(s) '
'from disk',
);
}
}
} catch (e) {
_logger.error('PersistentQueueStore: failed to load from disk — $e');
}
}