Update 16 Aug 2021
Binance has updated new Signature key format with SHA512 algorithm for more detail you can take a look at Binance api document.
String signature = timestamp.toString() + "\n" + nonce + "\n" + bytes +
"\n";
YOU MUST INCLUDE "\n"
My Code
I have try Signature key that print from this code on Binance payment api, everything work fine. (signature must be uppercase when you send request)
var key = utf8.encode('YOUR_SECRET_KEY'); // get from binance api
var timestamp = DateTime.now().millisecondsSinceEpoch;
var nonce = "asdopewrmweqjidsfnosd"; // Random 32 length String,
var bytes = '''{
"merchantId": "",
"subMerchantId": "",
"merchantTradeNo": "9825382937292117596",
"totalFee": 0.5,
"productDetail": "Greentea ice cream cone",
"currency": "USDT",
"returnUrl": "",
"tradeType": "WEB",
"productType": "Food",
"productName": "Ice Cream"
}''';
String payload = timestamp.toString() + "\n" + nonce + "\n" + bytes +
"\n";
var hmacSha512 = Hmac(sha512, key); // HMAC-SHA512/
var digest = hmacSha512.convert(utf8.encode(payload));
print(timestamp.toString() + "\n");
print("HMAC digest as hex string: ${digest.toString().toUpperCase()}");