listFromJson static method

List<RmlFileReference> listFromJson(
  1. String json
)

Reads the refs array native sends across FFI/wasm. Never throws: text that is not the expected shape yields no references.

Implementation

static List<RmlFileReference> listFromJson(String json) {
  try {
    final decoded = jsonDecode(json);
    if (decoded is! List) {
      return const [];
    }
    return [
      for (final entry in decoded.cast<Map<String, dynamic>>())
        RmlFileReference(
          id: entry['id'] as String,
          path: entry['path'] as String,
          line: entry['line'] as int,
        ),
    ];
  } catch (_) {
    return const [];
  }
}