getNetworkLogs method

Future<List<NetworkLog>> getNetworkLogs()

Reads all network logs from persistent storage.

The logs are read from a file named network_logs.jsonl within the application support directory. The logs are read in JSON Lines format.

The logs are read asynchronously in a separate isolate to avoid blocking the main isolate.

The logs are returned as a list of NetworkLog objects.

Implementation

Future<List<NetworkLog>> getNetworkLogs() async {
  final dir = await getApplicationSupportDirectory();
  final rawLogs =
      await Isolate.run(() => IsolateLogWriter.readLogs(dir.path, 'network'));
  return rawLogs.map((e) => NetworkLog.fromJson(e)).toList();
}