CapturedUniformBlock.fromJson constructor

CapturedUniformBlock.fromJson(
  1. Map<String, Object?> json
)

Rebuilds a block from toJson output, keeping the name and values it was serialized with (a loaded capture has no shaders to resolve against).

Implementation

factory CapturedUniformBlock.fromJson(Map<String, Object?> json) {
  final raw = json['data'];
  final bytes = raw is String ? base64Decode(raw) : Uint8List(0);
  final values = json['values'];
  return CapturedUniformBlock(
    ByteData.sublistView(bytes),
    resolvedName: json['name'] as String?,
    resolvedValues: values is List
        ? [
            for (final value in values.cast<Map>())
              (
                name: value['name'] as String,
                type: value['type'] as String,
                values: (value['values'] as List).cast<num>(),
              ),
          ]
        : null,
  );
}