From 4a8784f508da0d9220fb16123fec162f43837eb4 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sat, 10 Apr 2021 20:10:46 +0800 Subject: [PATCH] Fix rational list not converted from/to json correctly --- lib/entity/exif.dart | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/entity/exif.dart b/lib/entity/exif.dart index 02165bf6..f163291a 100644 --- a/lib/entity/exif.dart +++ b/lib/entity/exif.dart @@ -17,8 +17,14 @@ class Exif { jsonValue = base64UrlEncode(value); } else if (value is Rational) { jsonValue = value.toJson(); - } else if (value is List) { - jsonValue = value.map((e) => e.toJson()).toList(); + } else if (value is List) { + jsonValue = value.map((e) { + if (e is Rational) { + return e.toJson(); + } else { + return e; + } + }).toList(); } else { jsonValue = value; } @@ -33,10 +39,14 @@ class Exif { exifValue = base64Decode(value); } else if (value is Map) { exifValue = Rational.fromJson(value.cast()); - } else if (value is List) { - exifValue = value - .map((e) => Rational.fromJson(e.cast())) - .toList(); + } else if (value is List) { + exifValue = value.map((e) { + if (e is Map) { + return Rational.fromJson(e.cast()); + } else { + return value; + } + }).toList(); } else { exifValue = value; }