need some help to convert Hex String to Ascii string.
I am using sample functions from here
Sample Hex = 20354653474955 I am getting this error:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: RangeError (end): Invalid value: Not in inclusive range 20..21: 22
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: FormatException: Invalid radix-16 number (at character 1)
Any suggestion to get this work on Dart?
Here is the function I am using:
String hexToAscii(String hexString) => List.generate(
hexString.length ~/ 2,
(i) => String.fromCharCode(int.parse(hexString.substring(i * 2, (i * 2) + 2), radix: 16)),
).join();
I figured it out. The substring argument (i *2,(i *2) +2) seems incorrect. It was skipping some sequences of the Hex string.