decimalToHex static method
Implementation
static String decimalToHex(int number, [int minDigits = 1]) {
final hexDigits = '0123456789abcdef';
var result = <String>[];
var dividend = number >> 4;
var remain = number % 16;
result.add(hexDigits[remain]);
while (dividend != 0) {
remain = dividend % 16;
dividend >>= 4;
result.add(hexDigits[remain]);
}
var invertResult = StringBuffer();
var paddings = minDigits - result.length;
while (paddings-- > 0) {
invertResult.write('0');
}
for (var i = result.length - 1; i >= 0; i--) {
invertResult.write(result[i]);
}
return invertResult.toString();
}