Denis Portnov
2018-06-11 22:53:26 UTC
Hi all,
What is idiomatic way in Dart 2 for representing byte array? What type to
use?
I see that io, convert, crypto etc. all require or produce byte arrays as
List<int>
It's not very convenient for library author as it requires either to
check/truncate individual ints from List, or use Uint8List.fromList()
everywhere.
Flutter explicitly goes with Uint8List
https://docs.flutter.io/flutter/widgets/Image/Image.memory.html
So let's say I'm doing library for IP address, UUID, hash, or any structure
with underlying byte array.
Is it fine to have this
class IPAddress {
IPAddress.fromBytes(Uint8List bytes) {}
Uint8List get bytes;
}
class SomeBinaryEncoder extends Converter<Uint8List, Uint8List> {
Uint8List convert(Uint8List input) {}
}
Thanks
Denis
What is idiomatic way in Dart 2 for representing byte array? What type to
use?
I see that io, convert, crypto etc. all require or produce byte arrays as
List<int>
It's not very convenient for library author as it requires either to
check/truncate individual ints from List, or use Uint8List.fromList()
everywhere.
Flutter explicitly goes with Uint8List
https://docs.flutter.io/flutter/widgets/Image/Image.memory.html
So let's say I'm doing library for IP address, UUID, hash, or any structure
with underlying byte array.
Is it fine to have this
class IPAddress {
IPAddress.fromBytes(Uint8List bytes) {}
Uint8List get bytes;
}
class SomeBinaryEncoder extends Converter<Uint8List, Uint8List> {
Uint8List convert(Uint8List input) {}
}
Thanks
Denis
--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/478c312b-8066-4e22-9bc3-9ed524e5016b%40dartlang.org.
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/478c312b-8066-4e22-9bc3-9ed524e5016b%40dartlang.org.