decodeSectionJson function
The JSON document bytes hold, or a BundleSectionFormatException saying
why they hold none: the SDK's own FormatException from the UTF-8 or JSON
decoder is the one thing a section decoder would otherwise let out bare.
Implementation
Object? decodeSectionJson(ByteData bytes) {
try {
return jsonDecode(
utf8.decode(
bytes.buffer.asUint8List(bytes.offsetInBytes, bytes.lengthInBytes),
),
);
} on FormatException catch (error) {
throw BundleSectionFormatException(
'the section is not UTF-8 JSON: ${error.message}',
);
}
}