So there's the 'dart:convert'
library, which contains a HexDecoder class that doesn't seem to have a constructor (according to this). But importing it and trying to construct it doesn't work; I thought maybe there was a default constructor not mentioned.
I could copy the code in the source for the convert method, but I'd rather make this a learning opportunity. Any help would be appreciated.
Each Hexadecimal character represents 4 bits (0 - 15 decimal) which is called a nibble (a small byte - honest!). A byte (or octet) is 8 bits so is always represented by 2 Hex characters in the range 00 to FF.
A powerful conversion of [String] or/and Hash to HEX. It returns a unique HEX, or a unique int of [Color()] per provided String/hash. It's provided two methods [toHexString] and [toColor], which return a Hex-String, or integer of Color() respectively.
Uint8List is a list of integers where the values in the list are only 8 bits each, or one byte. The U of Uint8List means unsigned, so the values range from 0 to 255 . That's perfect for representing binary data!
HexDecoder
isn't actually in dart:convert
. It's in a package (also) called convert
.
You need to add it to your pubspec.yaml
and then use an import like:
import 'package:convert/convert.dart';
Then use it like this:
hex.decode('abcdef');
hex
is a const singleton instance of the codec. (The constructor is private; you don't need to instantiate your own - use the existing const instance.)
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