obtainPathFromProperties static method
Future<AssetPathEntity>
obtainPathFromProperties({
- required String id,
- int albumType = 1,
- RequestType type = RequestType.common,
- PMFilter? optionGroup,
- bool maxDateTimeToNow = true,
Call this method to obtain new path entity.
Implementation
static Future<AssetPathEntity> obtainPathFromProperties({
required String id,
int albumType = 1,
RequestType type = RequestType.common,
PMFilter? optionGroup,
bool maxDateTimeToNow = true,
}) async {
optionGroup ??= FilterOptionGroup();
final StateError error = StateError(
'Unable to fetch properties for path $id.',
);
if (maxDateTimeToNow) {
if (optionGroup is FilterOptionGroup) {
optionGroup = optionGroup.copyWith(
createTimeCond: optionGroup.createTimeCond.copyWith(
max: DateTime.now(),
),
updateTimeCond: optionGroup.updateTimeCond.copyWith(
max: DateTime.now(),
),
);
}
} else {
optionGroup = optionGroup;
}
final Map<dynamic, dynamic>? result = await plugin.fetchPathProperties(
id,
type,
optionGroup,
);
if (result == null) {
throw error;
}
final Object? list = result['data'];
if (list is List && list.isNotEmpty) {
return ConvertUtils.convertToPathList(
result.cast<String, dynamic>(),
type: type,
filterOption: optionGroup,
).first;
}
throw error;
}