encode method
Implementation
String encode(int dec) {
int mod = 16;
int count = dec;
List<int> hexList = [];
for (; count > 0;) {
var ans1 = count / mod;
var mod1 = ans1.round();
var ans = count - (mod1 * mod);
if (ans < 0) {
mod1 -= 1;
ans = count - ((mod1) * mod);
}
count = mod1;
hexList.add(ans);
}
int length = hexList.length - 1;
String hex = '';
for (int i = length; i >= 0; i--) {
var num = hexList[i];
if (num < mod) {
if (num > 9) {
hex += _charEncode(num);
} else {
hex += num.toString();
}
}
}
return hex;
}