load static method

List<SocketLane> load(
  1. String path
)

Reads path and parses simulation.whitelist. A missing file or a missing key yields the empty (safe) whitelist. Malformed entries throw FormatException — a lane that cannot be parsed must never silently open network access.

Implementation

static List<SocketLane> load(String path) {
  final file = File(path);
  if (!file.existsSync()) return const [];
  Map<String, dynamic> doc;
  try {
    doc = jsonDecode(file.readAsStringSync()) as Map<String, dynamic>;
  } on FormatException {
    rethrow;
  } on TypeError {
    throw const FormatException('project config is not a JSON object');
  }
  final simulation = doc['simulation'];
  if (simulation is! Map<String, dynamic>) return const [];
  final whitelist = simulation['whitelist'];
  if (whitelist is! List) return const [];
  return whitelist.map(_parseEntry).toList();
}