What is the maximum number of characters can dart String class can hold? I searched about this question in Google Search and I can't found the answer.
What is the maximum number of characters can dart String class can hold? I searched about this question in Google Search and I can't found the answer.
It depends.
When compiled for the web, the limit is the allowed JS String length.
Checking, it seems Chrome has a 0x1FFF_FFE8 limit on string length, Firefox uses 0x3FFF_FFFE.
On the Dart native VM, the limit is memory (and the size of integers, but so far the 64-bit integers cannot be a limiting factor on contemporary hardware. You can't actually have 2^64 bytes of memory on any current 64-bit architecture.) I ran into "Exhausted heap space" errors after trying to double a string of length 0x4_0000_0000 (16 Gb). At that point the code was already fairly slow, which is not surprising since the computer "only" has 32 Gb of physical memory.
If using a 32-bit VM, the memory limit will definitely be lower.