Safe parse h/w from public magicMetadata
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import "dart:convert";
|
||||
|
||||
import "package:flutter/cupertino.dart";
|
||||
import 'package:photos/models/metadata/common_keys.dart';
|
||||
|
||||
const editTimeKey = 'editedTime';
|
||||
@@ -88,8 +89,8 @@ class PubMagicMetadata {
|
||||
editedName: map[editNameKey],
|
||||
caption: map[captionKey],
|
||||
uploaderName: map[uploaderNameKey],
|
||||
w: map[widthKey],
|
||||
h: map[heightKey],
|
||||
w: safeParseInt(map[widthKey], widthKey),
|
||||
h: safeParseInt(map[heightKey], heightKey),
|
||||
lat: map[latKey],
|
||||
long: map[longKey],
|
||||
mvi: map[motionVideoIndexKey],
|
||||
@@ -97,4 +98,12 @@ class PubMagicMetadata {
|
||||
mediaType: map[mediaTypeKey],
|
||||
);
|
||||
}
|
||||
|
||||
static int? safeParseInt(dynamic value, String key) {
|
||||
if (value == null) return null;
|
||||
if (value is int) return value;
|
||||
debugPrint("PubMagicMetadata key: $key Unexpected value: $value");
|
||||
if (value is String) return int.tryParse(value);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user