diff --git a/lib/src/utils/utils.dart b/lib/src/utils/utils.dart index fbc4ed6..e20ca26 100644 --- a/lib/src/utils/utils.dart +++ b/lib/src/utils/utils.dart @@ -141,5 +141,5 @@ bool isExpectConversion(int tag) { const bool kIsWeb = identical(0, 0.0); bool isWebDouble(Object a) { - return (a as double).toInt() == a; + return a is double && a.toInt() == a; } diff --git a/lib/src/value/value.dart b/lib/src/value/value.dart index 9cbd1da..d5a4d21 100644 --- a/lib/src/value/value.dart +++ b/lib/src/value/value.dart @@ -62,8 +62,8 @@ abstract class CborValue { return CborNull(); } else if (object is CborValue) { return object; - } else if (!kIsWeb && object is double || kIsWeb && isWebDouble(object)) { - return CborFloat(object as double); + } else if (object is double && (!kIsWeb || kIsWeb && isWebDouble(object))) { + return CborFloat(object); } else if (object is int) { return CborSmallInt(object); } else if (object is BigInt) {