Hi Mahesh,
Only lists that are backed by native memory can be shared from Dart to C/Java.
There are only two such types of list:
1. Pointer from dart:ffi
2. "external" TypedData (external means memory external to Dart), which can be constructed with Pointer.asTypedList.
> Is there any way to get reference to a dart List<T>'s underlying buffer?
No, List<int> is most likely a list in Dart memory, so it cannot be shared with C/Java. The garbage collector might move the list at any time and the representation is not compatible with C.
> Does dart make any guarantees about int representation?
The representation in Dart of integers cannot be shared with C/Java."Smi"s, or small integers, are bit shifted 1 bit to the left, and "Mint"s or medium size integers are boxed in an object.
Hi Daco,
Take a look at gsoc_jni2 repo I shared with you, particularly lib/Toast.dart Toast#calcByteSum, this seems to work with typed lists like UintList.
I have a question:
* Is there any way to get reference to a dart List<T>'s underlying buffer? I thought it is not possible because ints are technically object in dart. Does dart make any guarantees about int representation?