retain existing behavior

This commit is contained in:
shenlong-tanwen 2025-05-17 19:57:36 +05:30
parent ac70d03693
commit 8e71287bbc
42 changed files with 158 additions and 152 deletions

View File

@ -163,8 +163,7 @@ class Album {
dto.order == AssetOrder.asc ? SortOrder.asc : SortOrder.desc;
}
if (dto.albumThumbnailAssetId != null &&
dto.albumThumbnailAssetId!.isSome) {
if (dto.albumThumbnailAssetId?.unwrapOrNull() != null) {
a.thumbnail.value = await db.assets
.where()
.remoteIdEqualTo(dto.albumThumbnailAssetId!.unwrap())

View File

@ -62,11 +62,11 @@ class SearchService {
SmartSearchDto(
query: filter.context!,
language: filter.language,
country: Option.from(filter.location.country),
state: Option.from(filter.location.state),
city: Option.from(filter.location.city),
country: Some.tryFrom(filter.location.country),
state: Some.tryFrom(filter.location.state),
city: Some.tryFrom(filter.location.city),
make: filter.camera.make,
model: Option.from(filter.camera.model),
model: Some.tryFrom(filter.camera.model),
takenAfter: filter.date.takenAfter,
takenBefore: filter.date.takenBefore,
visibility: filter.display.isArchive
@ -87,15 +87,15 @@ class SearchService {
filter.filename != null && filter.filename!.isNotEmpty
? filter.filename
: null,
country: Option.from(filter.location.country),
country: Some.tryFrom(filter.location.country),
description:
filter.description != null && filter.description!.isNotEmpty
? filter.description
: null,
state: Option.from(filter.location.state),
city: Option.from(filter.location.city),
state: Some.tryFrom(filter.location.state),
city: Some.tryFrom(filter.location.city),
make: filter.camera.make,
model: Option.from(filter.camera.model),
model: Some.tryFrom(filter.camera.model),
takenAfter: filter.date.takenAfter,
takenBefore: filter.date.takenBefore,
visibility: filter.display.isArchive

View File

@ -57,7 +57,7 @@ class SharedLinkService {
showMetadata: showMeta,
allowDownload: allowDownload,
allowUpload: allowUpload,
expiresAt: Option.from(expiresAt),
expiresAt: Some.tryFrom(expiresAt),
description: description,
password: password,
);
@ -67,7 +67,7 @@ class SharedLinkService {
showMetadata: showMeta,
allowDownload: allowDownload,
allowUpload: allowUpload,
expiresAt: Option.from(expiresAt),
expiresAt: Some.tryFrom(expiresAt),
description: description,
password: password,
assetIds: assetIds,
@ -104,7 +104,7 @@ class SharedLinkService {
showMetadata: showMeta,
allowDownload: allowDownload,
allowUpload: allowUpload,
expiresAt: Option.from(expiresAt),
expiresAt: Some.tryFrom(expiresAt),
description: description,
password: password,
changeExpiryTime: changeExpiry,

View File

@ -66,6 +66,13 @@ class Some<T> extends Option<T> {
final T value;
const Some(this.value);
static Some<U>? tryFrom<U>(U? value) {
if (value == null) {
return null;
}
return Some(value);
}
}
class None extends Option<Never> {

View File

@ -87,8 +87,8 @@ class ActivityResponseDto {
final json = value.cast<String, dynamic>();
return ActivityResponseDto(
assetId: Option.from(mapValueOfType<String>(json, r'assetId')),
comment: Option.from(mapValueOfType<String>(json, r'comment')),
assetId: Some.tryFrom(mapValueOfType<String>(json, r'assetId')),
comment: Some.tryFrom(mapValueOfType<String>(json, r'comment')),
createdAt: mapDateTime(json, r'createdAt', r'')!,
id: mapValueOfType<String>(json, r'id')!,
type: ReactionType.fromJson(json[r'type'])!,

View File

@ -194,7 +194,7 @@ class AlbumResponseDto {
return AlbumResponseDto(
albumName: mapValueOfType<String>(json, r'albumName')!,
albumThumbnailAssetId: Option.from(mapValueOfType<String>(json, r'albumThumbnailAssetId')),
albumThumbnailAssetId: Some.tryFrom(mapValueOfType<String>(json, r'albumThumbnailAssetId')),
albumUsers: AlbumUserResponseDto.listFromJson(json[r'albumUsers']),
assetCount: mapValueOfType<int>(json, r'assetCount')!,
assets: AssetResponseDto.listFromJson(json[r'assets']),

View File

@ -156,7 +156,7 @@ class AssetBulkUpdateDto {
return AssetBulkUpdateDto(
dateTimeOriginal: mapValueOfType<String>(json, r'dateTimeOriginal'),
duplicateId: Option.from(mapValueOfType<String>(json, r'duplicateId')),
duplicateId: Some.tryFrom(mapValueOfType<String>(json, r'duplicateId')),
ids: json[r'ids'] is Iterable
? (json[r'ids'] as Iterable).cast<String>().toList(growable: false)
: const [],

View File

@ -116,7 +116,7 @@ class AssetFaceResponseDto {
id: mapValueOfType<String>(json, r'id')!,
imageHeight: mapValueOfType<int>(json, r'imageHeight')!,
imageWidth: mapValueOfType<int>(json, r'imageWidth')!,
person: Option.from(PersonResponseDto.fromJson(json[r'person'])),
person: Some.tryFrom(PersonResponseDto.fromJson(json[r'person'])),
sourceType: SourceType.fromJson(json[r'sourceType']),
);
}

View File

@ -301,7 +301,7 @@ class AssetResponseDto {
checksum: mapValueOfType<String>(json, r'checksum')!,
deviceAssetId: mapValueOfType<String>(json, r'deviceAssetId')!,
deviceId: mapValueOfType<String>(json, r'deviceId')!,
duplicateId: Option.from(mapValueOfType<String>(json, r'duplicateId')),
duplicateId: Some.tryFrom(mapValueOfType<String>(json, r'duplicateId')),
duration: mapValueOfType<String>(json, r'duration')!,
exifInfo: ExifResponseDto.fromJson(json[r'exifInfo']),
fileCreatedAt: mapDateTime(json, r'fileCreatedAt', r'')!,
@ -312,8 +312,8 @@ class AssetResponseDto {
isFavorite: mapValueOfType<bool>(json, r'isFavorite')!,
isOffline: mapValueOfType<bool>(json, r'isOffline')!,
isTrashed: mapValueOfType<bool>(json, r'isTrashed')!,
libraryId: Option.from(mapValueOfType<String>(json, r'libraryId')),
livePhotoVideoId: Option.from(mapValueOfType<String>(json, r'livePhotoVideoId')),
libraryId: Some.tryFrom(mapValueOfType<String>(json, r'libraryId')),
livePhotoVideoId: Some.tryFrom(mapValueOfType<String>(json, r'livePhotoVideoId')),
localDateTime: mapDateTime(json, r'localDateTime', r'')!,
originalFileName: mapValueOfType<String>(json, r'originalFileName')!,
originalMimeType: mapValueOfType<String>(json, r'originalMimeType'),
@ -322,9 +322,9 @@ class AssetResponseDto {
ownerId: mapValueOfType<String>(json, r'ownerId')!,
people: PersonWithFacesResponseDto.listFromJson(json[r'people']),
resized: mapValueOfType<bool>(json, r'resized'),
stack: Option.from(AssetStackResponseDto.fromJson(json[r'stack'])),
stack: Some.tryFrom(AssetStackResponseDto.fromJson(json[r'stack'])),
tags: TagResponseDto.listFromJson(json[r'tags']),
thumbhash: Option.from(mapValueOfType<String>(json, r'thumbhash')),
thumbhash: Some.tryFrom(mapValueOfType<String>(json, r'thumbhash')),
type: AssetTypeEnum.fromJson(json[r'type'])!,
unassignedFaces: AssetFaceWithoutPersonResponseDto.listFromJson(json[r'unassignedFaces']),
updatedAt: mapDateTime(json, r'updatedAt', r'')!,

View File

@ -303,44 +303,44 @@ class ExifResponseDto {
final json = value.cast<String, dynamic>();
return ExifResponseDto(
city: Option.from(mapValueOfType<String>(json, r'city')),
country: Option.from(mapValueOfType<String>(json, r'country')),
dateTimeOriginal: Option.from(mapDateTime(json, r'dateTimeOriginal', r'')),
description: Option.from(mapValueOfType<String>(json, r'description')),
exifImageHeight: Option.from(json[r'exifImageHeight'] == null
city: Some.tryFrom(mapValueOfType<String>(json, r'city')),
country: Some.tryFrom(mapValueOfType<String>(json, r'country')),
dateTimeOriginal: Some.tryFrom(mapDateTime(json, r'dateTimeOriginal', r'')),
description: Some.tryFrom(mapValueOfType<String>(json, r'description')),
exifImageHeight: Some.tryFrom(json[r'exifImageHeight'] == null
? null
: num.parse('${json[r'exifImageHeight']}')),
exifImageWidth: Option.from(json[r'exifImageWidth'] == null
exifImageWidth: Some.tryFrom(json[r'exifImageWidth'] == null
? null
: num.parse('${json[r'exifImageWidth']}')),
exposureTime: Option.from(mapValueOfType<String>(json, r'exposureTime')),
fNumber: Option.from(json[r'fNumber'] == null
exposureTime: Some.tryFrom(mapValueOfType<String>(json, r'exposureTime')),
fNumber: Some.tryFrom(json[r'fNumber'] == null
? null
: num.parse('${json[r'fNumber']}')),
fileSizeInByte: Option.from(mapValueOfType<int>(json, r'fileSizeInByte')),
focalLength: Option.from(json[r'focalLength'] == null
fileSizeInByte: Some.tryFrom(mapValueOfType<int>(json, r'fileSizeInByte')),
focalLength: Some.tryFrom(json[r'focalLength'] == null
? null
: num.parse('${json[r'focalLength']}')),
iso: Option.from(json[r'iso'] == null
iso: Some.tryFrom(json[r'iso'] == null
? null
: num.parse('${json[r'iso']}')),
latitude: Option.from(json[r'latitude'] == null
latitude: Some.tryFrom(json[r'latitude'] == null
? null
: num.parse('${json[r'latitude']}')),
lensModel: Option.from(mapValueOfType<String>(json, r'lensModel')),
longitude: Option.from(json[r'longitude'] == null
lensModel: Some.tryFrom(mapValueOfType<String>(json, r'lensModel')),
longitude: Some.tryFrom(json[r'longitude'] == null
? null
: num.parse('${json[r'longitude']}')),
make: Option.from(mapValueOfType<String>(json, r'make')),
model: Option.from(mapValueOfType<String>(json, r'model')),
modifyDate: Option.from(mapDateTime(json, r'modifyDate', r'')),
orientation: Option.from(mapValueOfType<String>(json, r'orientation')),
projectionType: Option.from(mapValueOfType<String>(json, r'projectionType')),
rating: Option.from(json[r'rating'] == null
make: Some.tryFrom(mapValueOfType<String>(json, r'make')),
model: Some.tryFrom(mapValueOfType<String>(json, r'model')),
modifyDate: Some.tryFrom(mapDateTime(json, r'modifyDate', r'')),
orientation: Some.tryFrom(mapValueOfType<String>(json, r'orientation')),
projectionType: Some.tryFrom(mapValueOfType<String>(json, r'projectionType')),
rating: Some.tryFrom(json[r'rating'] == null
? null
: num.parse('${json[r'rating']}')),
state: Option.from(mapValueOfType<String>(json, r'state')),
timeZone: Option.from(mapValueOfType<String>(json, r'timeZone')),
state: Some.tryFrom(mapValueOfType<String>(json, r'state')),
timeZone: Some.tryFrom(mapValueOfType<String>(json, r'timeZone')),
);
}
return null;

View File

@ -110,7 +110,7 @@ class LibraryResponseDto {
: const [],
name: mapValueOfType<String>(json, r'name')!,
ownerId: mapValueOfType<String>(json, r'ownerId')!,
refreshedAt: Option.from(mapDateTime(json, r'refreshedAt', r'')),
refreshedAt: Some.tryFrom(mapDateTime(json, r'refreshedAt', r'')),
updatedAt: mapDateTime(json, r'updatedAt', r'')!,
);
}

View File

@ -93,12 +93,12 @@ class MapMarkerResponseDto {
final json = value.cast<String, dynamic>();
return MapMarkerResponseDto(
city: Option.from(mapValueOfType<String>(json, r'city')),
country: Option.from(mapValueOfType<String>(json, r'country')),
city: Some.tryFrom(mapValueOfType<String>(json, r'city')),
country: Some.tryFrom(mapValueOfType<String>(json, r'country')),
id: mapValueOfType<String>(json, r'id')!,
lat: (mapValueOfType<num>(json, r'lat')!).toDouble(),
lon: (mapValueOfType<num>(json, r'lon')!).toDouble(),
state: Option.from(mapValueOfType<String>(json, r'state')),
state: Some.tryFrom(mapValueOfType<String>(json, r'state')),
);
}
return null;

View File

@ -75,9 +75,9 @@ class MapReverseGeocodeResponseDto {
final json = value.cast<String, dynamic>();
return MapReverseGeocodeResponseDto(
city: Option.from(mapValueOfType<String>(json, r'city')),
country: Option.from(mapValueOfType<String>(json, r'country')),
state: Option.from(mapValueOfType<String>(json, r'state')),
city: Some.tryFrom(mapValueOfType<String>(json, r'city')),
country: Some.tryFrom(mapValueOfType<String>(json, r'country')),
state: Some.tryFrom(mapValueOfType<String>(json, r'state')),
);
}
return null;

View File

@ -663,8 +663,8 @@ class MetadataSearchDto {
return MetadataSearchDto(
checksum: mapValueOfType<String>(json, r'checksum'),
city: Option.from(mapValueOfType<String>(json, r'city')),
country: Option.from(mapValueOfType<String>(json, r'country')),
city: Some.tryFrom(mapValueOfType<String>(json, r'city')),
country: Some.tryFrom(mapValueOfType<String>(json, r'country')),
createdAfter: mapDateTime(json, r'createdAfter', r''),
createdBefore: mapDateTime(json, r'createdBefore', r''),
description: mapValueOfType<String>(json, r'description'),
@ -677,10 +677,10 @@ class MetadataSearchDto {
isMotion: mapValueOfType<bool>(json, r'isMotion'),
isNotInAlbum: mapValueOfType<bool>(json, r'isNotInAlbum'),
isOffline: mapValueOfType<bool>(json, r'isOffline'),
lensModel: Option.from(mapValueOfType<String>(json, r'lensModel')),
libraryId: Option.from(mapValueOfType<String>(json, r'libraryId')),
lensModel: Some.tryFrom(mapValueOfType<String>(json, r'lensModel')),
libraryId: Some.tryFrom(mapValueOfType<String>(json, r'libraryId')),
make: mapValueOfType<String>(json, r'make'),
model: Option.from(mapValueOfType<String>(json, r'model')),
model: Some.tryFrom(mapValueOfType<String>(json, r'model')),
order: AssetOrder.fromJson(json[r'order']) ?? AssetOrder.desc,
originalFileName: mapValueOfType<String>(json, r'originalFileName'),
originalPath: mapValueOfType<String>(json, r'originalPath'),
@ -691,7 +691,7 @@ class MetadataSearchDto {
previewPath: mapValueOfType<String>(json, r'previewPath'),
rating: num.parse('${json[r'rating']}'),
size: num.parse('${json[r'size']}'),
state: Option.from(mapValueOfType<String>(json, r'state')),
state: Some.tryFrom(mapValueOfType<String>(json, r'state')),
tagIds: json[r'tagIds'] is Iterable
? (json[r'tagIds'] as Iterable).cast<String>().toList(growable: false)
: const [],

View File

@ -124,9 +124,9 @@ class NotificationCreateDto {
return NotificationCreateDto(
data: mapValueOfType<Object>(json, r'data'),
description: Option.from(mapValueOfType<String>(json, r'description')),
description: Some.tryFrom(mapValueOfType<String>(json, r'description')),
level: NotificationLevel.fromJson(json[r'level']),
readAt: Option.from(mapDateTime(json, r'readAt', r'')),
readAt: Some.tryFrom(mapDateTime(json, r'readAt', r'')),
title: mapValueOfType<String>(json, r'title')!,
type: NotificationType.fromJson(json[r'type']),
userId: mapValueOfType<String>(json, r'userId')!,

View File

@ -60,7 +60,7 @@ class NotificationUpdateAllDto {
ids: json[r'ids'] is Iterable
? (json[r'ids'] as Iterable).cast<String>().toList(growable: false)
: const [],
readAt: Option.from(mapDateTime(json, r'readAt', r'')),
readAt: Some.tryFrom(mapDateTime(json, r'readAt', r'')),
);
}
return null;

View File

@ -51,7 +51,7 @@ class NotificationUpdateDto {
final json = value.cast<String, dynamic>();
return NotificationUpdateDto(
readAt: Option.from(mapDateTime(json, r'readAt', r'')),
readAt: Some.tryFrom(mapDateTime(json, r'readAt', r'')),
);
}
return null;

View File

@ -138,8 +138,8 @@ class PeopleUpdateItem {
final json = value.cast<String, dynamic>();
return PeopleUpdateItem(
birthDate: Option.from(mapDateTime(json, r'birthDate', r'')),
color: Option.from(mapValueOfType<String>(json, r'color')),
birthDate: Some.tryFrom(mapDateTime(json, r'birthDate', r'')),
color: Some.tryFrom(mapValueOfType<String>(json, r'color')),
featureFaceAssetId: mapValueOfType<String>(json, r'featureFaceAssetId'),
id: mapValueOfType<String>(json, r'id')!,
isFavorite: mapValueOfType<bool>(json, r'isFavorite'),

View File

@ -114,8 +114,8 @@ class PersonCreateDto {
final json = value.cast<String, dynamic>();
return PersonCreateDto(
birthDate: Option.from(mapDateTime(json, r'birthDate', r'')),
color: Option.from(mapValueOfType<String>(json, r'color')),
birthDate: Some.tryFrom(mapDateTime(json, r'birthDate', r'')),
color: Some.tryFrom(mapValueOfType<String>(json, r'color')),
isFavorite: mapValueOfType<bool>(json, r'isFavorite'),
isHidden: mapValueOfType<bool>(json, r'isHidden'),
name: mapValueOfType<String>(json, r'name'),

View File

@ -126,7 +126,7 @@ class PersonResponseDto {
final json = value.cast<String, dynamic>();
return PersonResponseDto(
birthDate: Option.from(mapDateTime(json, r'birthDate', r'')),
birthDate: Some.tryFrom(mapDateTime(json, r'birthDate', r'')),
color: mapValueOfType<String>(json, r'color'),
id: mapValueOfType<String>(json, r'id')!,
isFavorite: mapValueOfType<bool>(json, r'isFavorite'),

View File

@ -131,8 +131,8 @@ class PersonUpdateDto {
final json = value.cast<String, dynamic>();
return PersonUpdateDto(
birthDate: Option.from(mapDateTime(json, r'birthDate', r'')),
color: Option.from(mapValueOfType<String>(json, r'color')),
birthDate: Some.tryFrom(mapDateTime(json, r'birthDate', r'')),
color: Some.tryFrom(mapValueOfType<String>(json, r'color')),
featureFaceAssetId: mapValueOfType<String>(json, r'featureFaceAssetId'),
isFavorite: mapValueOfType<bool>(json, r'isFavorite'),
isHidden: mapValueOfType<bool>(json, r'isHidden'),

View File

@ -132,7 +132,7 @@ class PersonWithFacesResponseDto {
final json = value.cast<String, dynamic>();
return PersonWithFacesResponseDto(
birthDate: Option.from(mapDateTime(json, r'birthDate', r'')),
birthDate: Some.tryFrom(mapDateTime(json, r'birthDate', r'')),
color: mapValueOfType<String>(json, r'color'),
faces: AssetFaceWithoutPersonResponseDto.listFromJson(json[r'faces']),
id: mapValueOfType<String>(json, r'id')!,

View File

@ -495,8 +495,8 @@ class RandomSearchDto {
final json = value.cast<String, dynamic>();
return RandomSearchDto(
city: Option.from(mapValueOfType<String>(json, r'city')),
country: Option.from(mapValueOfType<String>(json, r'country')),
city: Some.tryFrom(mapValueOfType<String>(json, r'city')),
country: Some.tryFrom(mapValueOfType<String>(json, r'country')),
createdAfter: mapDateTime(json, r'createdAfter', r''),
createdBefore: mapDateTime(json, r'createdBefore', r''),
deviceId: mapValueOfType<String>(json, r'deviceId'),
@ -505,16 +505,16 @@ class RandomSearchDto {
isMotion: mapValueOfType<bool>(json, r'isMotion'),
isNotInAlbum: mapValueOfType<bool>(json, r'isNotInAlbum'),
isOffline: mapValueOfType<bool>(json, r'isOffline'),
lensModel: Option.from(mapValueOfType<String>(json, r'lensModel')),
libraryId: Option.from(mapValueOfType<String>(json, r'libraryId')),
lensModel: Some.tryFrom(mapValueOfType<String>(json, r'lensModel')),
libraryId: Some.tryFrom(mapValueOfType<String>(json, r'libraryId')),
make: mapValueOfType<String>(json, r'make'),
model: Option.from(mapValueOfType<String>(json, r'model')),
model: Some.tryFrom(mapValueOfType<String>(json, r'model')),
personIds: json[r'personIds'] is Iterable
? (json[r'personIds'] as Iterable).cast<String>().toList(growable: false)
: const [],
rating: num.parse('${json[r'rating']}'),
size: num.parse('${json[r'size']}'),
state: Option.from(mapValueOfType<String>(json, r'state')),
state: Some.tryFrom(mapValueOfType<String>(json, r'state')),
tagIds: json[r'tagIds'] is Iterable
? (json[r'tagIds'] as Iterable).cast<String>().toList(growable: false)
: const [],

View File

@ -63,8 +63,8 @@ class ReverseGeocodingStateResponseDto {
final json = value.cast<String, dynamic>();
return ReverseGeocodingStateResponseDto(
lastImportFileName: Option.from(mapValueOfType<String>(json, r'lastImportFileName')),
lastUpdate: Option.from(mapValueOfType<String>(json, r'lastUpdate')),
lastImportFileName: Some.tryFrom(mapValueOfType<String>(json, r'lastImportFileName')),
lastUpdate: Some.tryFrom(mapValueOfType<String>(json, r'lastUpdate')),
);
}
return null;

View File

@ -78,7 +78,7 @@ class SearchAssetResponseDto {
count: mapValueOfType<int>(json, r'count')!,
facets: SearchFacetResponseDto.listFromJson(json[r'facets']),
items: AssetResponseDto.listFromJson(json[r'items']),
nextPage: Option.from(mapValueOfType<String>(json, r'nextPage')),
nextPage: Some.tryFrom(mapValueOfType<String>(json, r'nextPage')),
total: mapValueOfType<int>(json, r'total')!,
);
}

View File

@ -146,7 +146,7 @@ class SharedLinkCreateDto {
? (json[r'assetIds'] as Iterable).cast<String>().toList(growable: false)
: const [],
description: mapValueOfType<String>(json, r'description'),
expiresAt: Option.from(mapDateTime(json, r'expiresAt', r'')),
expiresAt: Some.tryFrom(mapDateTime(json, r'expiresAt', r'')),
password: mapValueOfType<String>(json, r'password'),
showMetadata: mapValueOfType<bool>(json, r'showMetadata') ?? true,
type: SharedLinkType.fromJson(json[r'type'])!,

View File

@ -152,7 +152,7 @@ class SharedLinkEditDto {
allowUpload: mapValueOfType<bool>(json, r'allowUpload'),
changeExpiryTime: mapValueOfType<bool>(json, r'changeExpiryTime'),
description: mapValueOfType<String>(json, r'description'),
expiresAt: Option.from(mapDateTime(json, r'expiresAt', r'')),
expiresAt: Some.tryFrom(mapDateTime(json, r'expiresAt', r'')),
password: mapValueOfType<String>(json, r'password'),
showMetadata: mapValueOfType<bool>(json, r'showMetadata'),
);

View File

@ -162,13 +162,13 @@ class SharedLinkResponseDto {
allowUpload: mapValueOfType<bool>(json, r'allowUpload')!,
assets: AssetResponseDto.listFromJson(json[r'assets']),
createdAt: mapDateTime(json, r'createdAt', r'')!,
description: Option.from(mapValueOfType<String>(json, r'description')),
expiresAt: Option.from(mapDateTime(json, r'expiresAt', r'')),
description: Some.tryFrom(mapValueOfType<String>(json, r'description')),
expiresAt: Some.tryFrom(mapDateTime(json, r'expiresAt', r'')),
id: mapValueOfType<String>(json, r'id')!,
key: mapValueOfType<String>(json, r'key')!,
password: Option.from(mapValueOfType<String>(json, r'password')),
password: Some.tryFrom(mapValueOfType<String>(json, r'password')),
showMetadata: mapValueOfType<bool>(json, r'showMetadata')!,
token: Option.from(mapValueOfType<String>(json, r'token')),
token: Some.tryFrom(mapValueOfType<String>(json, r'token')),
type: SharedLinkType.fromJson(json[r'type'])!,
userId: mapValueOfType<String>(json, r'userId')!,
);

View File

@ -502,8 +502,8 @@ class SmartSearchDto {
final json = value.cast<String, dynamic>();
return SmartSearchDto(
city: Option.from(mapValueOfType<String>(json, r'city')),
country: Option.from(mapValueOfType<String>(json, r'country')),
city: Some.tryFrom(mapValueOfType<String>(json, r'city')),
country: Some.tryFrom(mapValueOfType<String>(json, r'country')),
createdAfter: mapDateTime(json, r'createdAfter', r''),
createdBefore: mapDateTime(json, r'createdBefore', r''),
deviceId: mapValueOfType<String>(json, r'deviceId'),
@ -513,10 +513,10 @@ class SmartSearchDto {
isNotInAlbum: mapValueOfType<bool>(json, r'isNotInAlbum'),
isOffline: mapValueOfType<bool>(json, r'isOffline'),
language: mapValueOfType<String>(json, r'language'),
lensModel: Option.from(mapValueOfType<String>(json, r'lensModel')),
libraryId: Option.from(mapValueOfType<String>(json, r'libraryId')),
lensModel: Some.tryFrom(mapValueOfType<String>(json, r'lensModel')),
libraryId: Some.tryFrom(mapValueOfType<String>(json, r'libraryId')),
make: mapValueOfType<String>(json, r'make'),
model: Option.from(mapValueOfType<String>(json, r'model')),
model: Some.tryFrom(mapValueOfType<String>(json, r'model')),
page: num.parse('${json[r'page']}'),
personIds: json[r'personIds'] is Iterable
? (json[r'personIds'] as Iterable).cast<String>().toList(growable: false)
@ -524,7 +524,7 @@ class SmartSearchDto {
query: mapValueOfType<String>(json, r'query')!,
rating: num.parse('${json[r'rating']}'),
size: num.parse('${json[r'size']}'),
state: Option.from(mapValueOfType<String>(json, r'state')),
state: Some.tryFrom(mapValueOfType<String>(json, r'state')),
tagIds: json[r'tagIds'] is Iterable
? (json[r'tagIds'] as Iterable).cast<String>().toList(growable: false)
: const [],

View File

@ -334,30 +334,30 @@ class SyncAssetExifV1 {
return SyncAssetExifV1(
assetId: mapValueOfType<String>(json, r'assetId')!,
city: Option.from(mapValueOfType<String>(json, r'city')),
country: Option.from(mapValueOfType<String>(json, r'country')),
dateTimeOriginal: Option.from(mapDateTime(json, r'dateTimeOriginal', r'')),
description: Option.from(mapValueOfType<String>(json, r'description')),
exifImageHeight: Option.from(mapValueOfType<int>(json, r'exifImageHeight')),
exifImageWidth: Option.from(mapValueOfType<int>(json, r'exifImageWidth')),
exposureTime: Option.from(mapValueOfType<String>(json, r'exposureTime')),
fNumber: Option.from(mapValueOfType<int>(json, r'fNumber')),
fileSizeInByte: Option.from(mapValueOfType<int>(json, r'fileSizeInByte')),
focalLength: Option.from(mapValueOfType<int>(json, r'focalLength')),
fps: Option.from(mapValueOfType<int>(json, r'fps')),
iso: Option.from(mapValueOfType<int>(json, r'iso')),
latitude: Option.from(mapValueOfType<int>(json, r'latitude')),
lensModel: Option.from(mapValueOfType<String>(json, r'lensModel')),
longitude: Option.from(mapValueOfType<int>(json, r'longitude')),
make: Option.from(mapValueOfType<String>(json, r'make')),
model: Option.from(mapValueOfType<String>(json, r'model')),
modifyDate: Option.from(mapDateTime(json, r'modifyDate', r'')),
orientation: Option.from(mapValueOfType<String>(json, r'orientation')),
profileDescription: Option.from(mapValueOfType<String>(json, r'profileDescription')),
projectionType: Option.from(mapValueOfType<String>(json, r'projectionType')),
rating: Option.from(mapValueOfType<int>(json, r'rating')),
state: Option.from(mapValueOfType<String>(json, r'state')),
timeZone: Option.from(mapValueOfType<String>(json, r'timeZone')),
city: Some.tryFrom(mapValueOfType<String>(json, r'city')),
country: Some.tryFrom(mapValueOfType<String>(json, r'country')),
dateTimeOriginal: Some.tryFrom(mapDateTime(json, r'dateTimeOriginal', r'')),
description: Some.tryFrom(mapValueOfType<String>(json, r'description')),
exifImageHeight: Some.tryFrom(mapValueOfType<int>(json, r'exifImageHeight')),
exifImageWidth: Some.tryFrom(mapValueOfType<int>(json, r'exifImageWidth')),
exposureTime: Some.tryFrom(mapValueOfType<String>(json, r'exposureTime')),
fNumber: Some.tryFrom(mapValueOfType<int>(json, r'fNumber')),
fileSizeInByte: Some.tryFrom(mapValueOfType<int>(json, r'fileSizeInByte')),
focalLength: Some.tryFrom(mapValueOfType<int>(json, r'focalLength')),
fps: Some.tryFrom(mapValueOfType<int>(json, r'fps')),
iso: Some.tryFrom(mapValueOfType<int>(json, r'iso')),
latitude: Some.tryFrom(mapValueOfType<int>(json, r'latitude')),
lensModel: Some.tryFrom(mapValueOfType<String>(json, r'lensModel')),
longitude: Some.tryFrom(mapValueOfType<int>(json, r'longitude')),
make: Some.tryFrom(mapValueOfType<String>(json, r'make')),
model: Some.tryFrom(mapValueOfType<String>(json, r'model')),
modifyDate: Some.tryFrom(mapDateTime(json, r'modifyDate', r'')),
orientation: Some.tryFrom(mapValueOfType<String>(json, r'orientation')),
profileDescription: Some.tryFrom(mapValueOfType<String>(json, r'profileDescription')),
projectionType: Some.tryFrom(mapValueOfType<String>(json, r'projectionType')),
rating: Some.tryFrom(mapValueOfType<int>(json, r'rating')),
state: Some.tryFrom(mapValueOfType<String>(json, r'state')),
timeZone: Some.tryFrom(mapValueOfType<String>(json, r'timeZone')),
);
}
return null;

View File

@ -136,14 +136,14 @@ class SyncAssetV1 {
return SyncAssetV1(
checksum: mapValueOfType<String>(json, r'checksum')!,
deletedAt: Option.from(mapDateTime(json, r'deletedAt', r'')),
fileCreatedAt: Option.from(mapDateTime(json, r'fileCreatedAt', r'')),
fileModifiedAt: Option.from(mapDateTime(json, r'fileModifiedAt', r'')),
deletedAt: Some.tryFrom(mapDateTime(json, r'deletedAt', r'')),
fileCreatedAt: Some.tryFrom(mapDateTime(json, r'fileCreatedAt', r'')),
fileModifiedAt: Some.tryFrom(mapDateTime(json, r'fileModifiedAt', r'')),
id: mapValueOfType<String>(json, r'id')!,
isFavorite: mapValueOfType<bool>(json, r'isFavorite')!,
localDateTime: Option.from(mapDateTime(json, r'localDateTime', r'')),
localDateTime: Some.tryFrom(mapDateTime(json, r'localDateTime', r'')),
ownerId: mapValueOfType<String>(json, r'ownerId')!,
thumbhash: Option.from(mapValueOfType<String>(json, r'thumbhash')),
thumbhash: Some.tryFrom(mapValueOfType<String>(json, r'thumbhash')),
type: SyncAssetV1TypeEnum.fromJson(json[r'type'])!,
visibility: SyncAssetV1VisibilityEnum.fromJson(json[r'visibility'])!,
);

View File

@ -69,7 +69,7 @@ class SyncUserV1 {
final json = value.cast<String, dynamic>();
return SyncUserV1(
deletedAt: Option.from(mapDateTime(json, r'deletedAt', r'')),
deletedAt: Some.tryFrom(mapDateTime(json, r'deletedAt', r'')),
email: mapValueOfType<String>(json, r'email')!,
id: mapValueOfType<String>(json, r'id')!,
name: mapValueOfType<String>(json, r'name')!,

View File

@ -75,7 +75,7 @@ class TagCreateDto {
return TagCreateDto(
color: mapValueOfType<String>(json, r'color'),
name: mapValueOfType<String>(json, r'name')!,
parentId: Option.from(mapValueOfType<String>(json, r'parentId')),
parentId: Some.tryFrom(mapValueOfType<String>(json, r'parentId')),
);
}
return null;

View File

@ -51,7 +51,7 @@ class TagUpdateDto {
final json = value.cast<String, dynamic>();
return TagUpdateDto(
color: Option.from(mapValueOfType<String>(json, r'color')),
color: Some.tryFrom(mapValueOfType<String>(json, r'color')),
);
}
return null;

View File

@ -169,7 +169,7 @@ class UpdateAssetDto {
description: mapValueOfType<String>(json, r'description'),
isFavorite: mapValueOfType<bool>(json, r'isFavorite'),
latitude: num.parse('${json[r'latitude']}'),
livePhotoVideoId: Option.from(mapValueOfType<String>(json, r'livePhotoVideoId')),
livePhotoVideoId: Some.tryFrom(mapValueOfType<String>(json, r'livePhotoVideoId')),
longitude: num.parse('${json[r'longitude']}'),
rating: num.parse('${json[r'rating']}'),
visibility: AssetVisibility.fromJson(json[r'visibility']),

View File

@ -94,7 +94,7 @@ class UsageByUserDto {
return UsageByUserDto(
photos: mapValueOfType<int>(json, r'photos')!,
quotaSizeInBytes: Option.from(mapValueOfType<int>(json, r'quotaSizeInBytes')),
quotaSizeInBytes: Some.tryFrom(mapValueOfType<int>(json, r'quotaSizeInBytes')),
usage: mapValueOfType<int>(json, r'usage')!,
usagePhotos: mapValueOfType<int>(json, r'usagePhotos')!,
usageVideos: mapValueOfType<int>(json, r'usageVideos')!,

View File

@ -126,14 +126,14 @@ class UserAdminCreateDto {
final json = value.cast<String, dynamic>();
return UserAdminCreateDto(
avatarColor: Option.from(UserAvatarColor.fromJson(json[r'avatarColor'])),
avatarColor: Some.tryFrom(UserAvatarColor.fromJson(json[r'avatarColor'])),
email: mapValueOfType<String>(json, r'email')!,
name: mapValueOfType<String>(json, r'name')!,
notify: mapValueOfType<bool>(json, r'notify'),
password: mapValueOfType<String>(json, r'password')!,
quotaSizeInBytes: Option.from(mapValueOfType<int>(json, r'quotaSizeInBytes')),
quotaSizeInBytes: Some.tryFrom(mapValueOfType<int>(json, r'quotaSizeInBytes')),
shouldChangePassword: mapValueOfType<bool>(json, r'shouldChangePassword'),
storageLabel: Option.from(mapValueOfType<String>(json, r'storageLabel')),
storageLabel: Some.tryFrom(mapValueOfType<String>(json, r'storageLabel')),
);
}
return null;

View File

@ -173,20 +173,20 @@ class UserAdminResponseDto {
return UserAdminResponseDto(
avatarColor: UserAvatarColor.fromJson(json[r'avatarColor'])!,
createdAt: mapDateTime(json, r'createdAt', r'')!,
deletedAt: Option.from(mapDateTime(json, r'deletedAt', r'')),
deletedAt: Some.tryFrom(mapDateTime(json, r'deletedAt', r'')),
email: mapValueOfType<String>(json, r'email')!,
id: mapValueOfType<String>(json, r'id')!,
isAdmin: mapValueOfType<bool>(json, r'isAdmin')!,
license: Option.from(UserLicense.fromJson(json[r'license'])),
license: Some.tryFrom(UserLicense.fromJson(json[r'license'])),
name: mapValueOfType<String>(json, r'name')!,
oauthId: mapValueOfType<String>(json, r'oauthId')!,
profileChangedAt: mapDateTime(json, r'profileChangedAt', r'')!,
profileImagePath: mapValueOfType<String>(json, r'profileImagePath')!,
quotaSizeInBytes: Option.from(mapValueOfType<int>(json, r'quotaSizeInBytes')),
quotaUsageInBytes: Option.from(mapValueOfType<int>(json, r'quotaUsageInBytes')),
quotaSizeInBytes: Some.tryFrom(mapValueOfType<int>(json, r'quotaSizeInBytes')),
quotaUsageInBytes: Some.tryFrom(mapValueOfType<int>(json, r'quotaUsageInBytes')),
shouldChangePassword: mapValueOfType<bool>(json, r'shouldChangePassword')!,
status: UserStatus.fromJson(json[r'status'])!,
storageLabel: Option.from(mapValueOfType<String>(json, r'storageLabel')),
storageLabel: Some.tryFrom(mapValueOfType<String>(json, r'storageLabel')),
updatedAt: mapDateTime(json, r'updatedAt', r'')!,
);
}

View File

@ -152,14 +152,14 @@ class UserAdminUpdateDto {
final json = value.cast<String, dynamic>();
return UserAdminUpdateDto(
avatarColor: Option.from(UserAvatarColor.fromJson(json[r'avatarColor'])),
avatarColor: Some.tryFrom(UserAvatarColor.fromJson(json[r'avatarColor'])),
email: mapValueOfType<String>(json, r'email'),
name: mapValueOfType<String>(json, r'name'),
password: mapValueOfType<String>(json, r'password'),
pinCode: Option.from(mapValueOfType<String>(json, r'pinCode')),
quotaSizeInBytes: Option.from(mapValueOfType<int>(json, r'quotaSizeInBytes')),
pinCode: Some.tryFrom(mapValueOfType<String>(json, r'pinCode')),
quotaSizeInBytes: Some.tryFrom(mapValueOfType<int>(json, r'quotaSizeInBytes')),
shouldChangePassword: mapValueOfType<bool>(json, r'shouldChangePassword'),
storageLabel: Option.from(mapValueOfType<String>(json, r'storageLabel')),
storageLabel: Some.tryFrom(mapValueOfType<String>(json, r'storageLabel')),
);
}
return null;

View File

@ -99,7 +99,7 @@ class UserUpdateMeDto {
final json = value.cast<String, dynamic>();
return UserUpdateMeDto(
avatarColor: Option.from(UserAvatarColor.fromJson(json[r'avatarColor'])),
avatarColor: Some.tryFrom(UserAvatarColor.fromJson(json[r'avatarColor'])),
email: mapValueOfType<String>(json, r'email'),
name: mapValueOfType<String>(json, r'name'),
password: mapValueOfType<String>(json, r'password'),

View File

@ -120,10 +120,10 @@ class {{{classname}}} {
return {{{classname}}}(
{{#vars}}
{{#isDateTime}}
{{{name}}}: {{#isNullable}}Option.from({{/isNullable}}mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
{{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
{{/isDateTime}}
{{#isDate}}
{{{name}}}: {{#isNullable}}Option.from({{/isNullable}}mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
{{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
{{/isDate}}
{{^isDateTime}}
{{^isDate}}
@ -181,7 +181,7 @@ class {{{classname}}} {
{{{name}}}: null, // No support for decoding binary content from JSON
{{/isBinary}}
{{^isBinary}}
{{{name}}}: {{#isNullable}}Option.from({{/isNullable}}{{{complexType}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
{{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}{{{complexType}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
{{/isBinary}}
{{/isMap}}
{{/isArray}}
@ -203,20 +203,20 @@ class {{{classname}}} {
{{/isMap}}
{{^isMap}}
{{#isNumber}}
{{{name}}}: {{#isNullable}}Option.from(json[r'{{{baseName}}}'] == null
{{{name}}}: {{#isNullable}}Some.tryFrom(json[r'{{{baseName}}}'] == null
? {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}
: {{/isNullable}}{{{datatypeWithEnum}}}.parse('${json[r'{{{baseName}}}']}'){{#isNullable}}){{/isNullable}},
{{/isNumber}}
{{#isDouble}}
{{{name}}}: {{#isNullable}}Option.from({{/isNullable}}(mapValueOfType<num>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}).toDouble(){{#isNullable}}){{/isNullable}},
{{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}(mapValueOfType<num>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}).toDouble(){{#isNullable}}){{/isNullable}},
{{/isDouble}}
{{^isDouble}}
{{^isNumber}}
{{^isEnum}}
{{{name}}}: {{#isNullable}}Option.from({{/isNullable}}mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
{{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
{{/isEnum}}
{{#isEnum}}
{{{name}}}: {{#isNullable}}Option.from({{/isNullable}}{{{enumName}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
{{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}{{{enumName}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
{{/isEnum}}
{{/isNumber}}
{{/isDouble}}

View File

@ -93,11 +93,11 @@ index 3a6c457..b1c8c5b 100644
{{#vars}}
{{#isDateTime}}
- {{{name}}}: mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
+ {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
+ {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
{{/isDateTime}}
{{#isDate}}
- {{{name}}}: mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
+ {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
+ {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
{{/isDate}}
{{^isDateTime}}
{{^isDate}}
@ -106,7 +106,7 @@ index 3a6c457..b1c8c5b 100644
{{/isBinary}}
{{^isBinary}}
- {{{name}}}: {{{complexType}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
+ {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}{{{complexType}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
+ {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}{{{complexType}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
{{/isBinary}}
{{/isMap}}
{{/isArray}}
@ -115,23 +115,23 @@ index 3a6c457..b1c8c5b 100644
{{^isMap}}
{{#isNumber}}
- {{{name}}}: {{#isNullable}}json[r'{{{baseName}}}'] == null
+ {{{name}}}: {{#isNullable}}Option.from(json[r'{{{baseName}}}'] == null
+ {{{name}}}: {{#isNullable}}Some.tryFrom(json[r'{{{baseName}}}'] == null
? {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}
- : {{/isNullable}}{{{datatypeWithEnum}}}.parse('${json[r'{{{baseName}}}']}'),
+ : {{/isNullable}}{{{datatypeWithEnum}}}.parse('${json[r'{{{baseName}}}']}'){{#isNullable}}){{/isNullable}},
{{/isNumber}}
+ {{#isDouble}}
+ {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}(mapValueOfType<num>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}).toDouble(){{#isNullable}}){{/isNullable}},
+ {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}(mapValueOfType<num>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}).toDouble(){{#isNullable}}){{/isNullable}},
+ {{/isDouble}}
+ {{^isDouble}}
{{^isNumber}}
{{^isEnum}}
- {{{name}}}: mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
+ {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
+ {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
{{/isEnum}}
{{#isEnum}}
- {{{name}}}: {{{enumName}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
+ {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}{{{enumName}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
+ {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}{{{enumName}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}},
{{/isEnum}}
{{/isNumber}}
+ {{/isDouble}}