Skip to content

Commit

Permalink
fix type detection error
Browse files Browse the repository at this point in the history
  • Loading branch information
dangfan committed Jan 19, 2024
1 parent d324e2c commit 00fdb84
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/src/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 2 additions & 2 deletions lib/src/value/value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 00fdb84

Please sign in to comment.