How can I decode a hexadecimal to a byte array in Dart? How can I decode a hexadecimal to a byte array in Dart? dart dart

How can I decode a hexadecimal to a byte array in Dart?


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.)