mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-22 18:44:31 +00:00
fix: Dart's stupid rounding
This commit is contained in:
parent
22a7763b26
commit
0ca5e46474
1 changed files with 16 additions and 5 deletions
|
@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/exchange/aggregate_currency.dart';
|
||||
import 'package:stackwallet/models/exchange/incomplete_exchange.dart';
|
||||
|
@ -152,10 +151,22 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
|||
return null;
|
||||
}
|
||||
try {
|
||||
final numFromLocalised = NumberFormat.decimalPattern(
|
||||
ref.read(localeServiceChangeNotifierProvider).locale)
|
||||
.parse(value);
|
||||
return Decimal.tryParse(numFromLocalised.toString());
|
||||
// wtf Dart?????
|
||||
// This turns "99999999999999999999" into 100000000000000000000.0
|
||||
// final numFromLocalised = NumberFormat.decimalPattern(
|
||||
// ref.read(localeServiceChangeNotifierProvider).locale)
|
||||
// .parse(value);
|
||||
// return Decimal.tryParse(numFromLocalised.toString());
|
||||
|
||||
try {
|
||||
return Decimal.parse(value);
|
||||
} catch (_) {
|
||||
try {
|
||||
return Decimal.parse(value.replaceAll(",", "."));
|
||||
} catch (_) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue