BigInt
Dart also has the BigInt type for representing arbitrary precision integers, which means that the size limit is the running computer's RAM. This type can be very useful depending on the context; however, it does not have the same performance as num types and you should consider this when deciding to use it.
JavaScript has the concept of safe integers, which Darts follows when transpiling to it. However, as JavaScript uses double-precision to represent even integers, we do not have an overflow when doing (maxInt * 2).
Now, you might consider putting BigInt everywhere you would use integers to be free of overflows, but remember, BigInt does not have the same performance as int types, making it unsuitable for all contexts.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access