fromJson static method

InitChunkedUploadRequest? fromJson(
  1. dynamic value
)

Returns a new InitChunkedUploadRequest instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static InitChunkedUploadRequest? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      assert(json.containsKey(r'fileName'), 'Required key "InitChunkedUploadRequest[fileName]" is missing from JSON.');
      assert(json[r'fileName'] != null, 'Required key "InitChunkedUploadRequest[fileName]" has a null value in JSON.');
      assert(json.containsKey(r'totalSize'), 'Required key "InitChunkedUploadRequest[totalSize]" is missing from JSON.');
      assert(json[r'totalSize'] != null, 'Required key "InitChunkedUploadRequest[totalSize]" has a null value in JSON.');
      assert(json.containsKey(r'mimeType'), 'Required key "InitChunkedUploadRequest[mimeType]" is missing from JSON.');
      assert(json[r'mimeType'] != null, 'Required key "InitChunkedUploadRequest[mimeType]" has a null value in JSON.');
      assert(json.containsKey(r'expectedBlocks'), 'Required key "InitChunkedUploadRequest[expectedBlocks]" is missing from JSON.');
      assert(json[r'expectedBlocks'] != null, 'Required key "InitChunkedUploadRequest[expectedBlocks]" has a null value in JSON.');
      return true;
    }());

    return InitChunkedUploadRequest(
      fileName: mapValueOfType<String>(json, r'fileName')!,
      totalSize: mapValueOfType<int>(json, r'totalSize')!,
      mimeType: mapValueOfType<String>(json, r'mimeType')!,
      expectedBlocks: json[r'expectedBlocks'] is Iterable
          ? (json[r'expectedBlocks'] as Iterable).cast<String>().toList(growable: false)
          : const [],
      folderId: mapValueOfType<String>(json, r'folderId'),
      workspaceId: mapValueOfType<String>(json, r'workspaceId'),
      organizationId: mapValueOfType<String>(json, r'organizationId'),
    );
  }
  return null;
}