allow "," decimal separator in qr code generator

This commit is contained in:
julian 2024-11-18 10:04:38 -06:00 committed by julian-CStack
parent b84c3ab2d3
commit 5496d2de96

View file

@ -144,7 +144,18 @@ class _GenerateUriQrCodeViewState extends State<GenerateUriQrCodeView> {
final amountString = amountController.text;
final noteString = noteController.text;
if (amountString.isNotEmpty && Decimal.tryParse(amountString) == null) {
// try "."
Decimal? amount = Decimal.tryParse(amountString);
if (amount == null) {
// try single instance of ","
final first = amountString.indexOf(",");
final last = amountString.lastIndexOf(",");
if (first == last) {
amount = Decimal.tryParse(amountString.replaceFirst(",", "."));
}
}
if (amountString.isNotEmpty && amount == null) {
showFloatingFlushBar(
type: FlushBarType.warning,
message: "Invalid amount",