For some reason, I am looking for an approach to get the size-of an object.
My target object is list or map<string,dynamic>.
I am looking through the document, there is sizeOf()
but doesn't have any arguments more.
Is there something wrong?
This should help. But I'm not sure it is working in your case. Please test it well.
import 'dart:convert';
final json = yourObject.toJson();
final jsonString = jsonEncode(json);
final jsonSizeInBytes = utf8.encode(jsonString).length;
print('JSON size: $jsonSizeInBytes bytes');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With