diff --git a/lib/screens/markets/order_book_chart.dart b/lib/screens/markets/order_book_chart.dart index 6030ece94..53aa08241 100644 --- a/lib/screens/markets/order_book_chart.dart +++ b/lib/screens/markets/order_book_chart.dart @@ -16,7 +16,6 @@ class OrderBookChart extends StatelessWidget { Widget build(BuildContext context) { final List _askTotals = []; final List _bidTotals = []; - double _maxAmount; for (int i = 0; i < sortedAsks.length; i++) { final double prevTotal = i > 0 ? _askTotals[_askTotals.length - 1] : 0; @@ -26,11 +25,10 @@ class OrderBookChart extends StatelessWidget { for (int i = 0; i < sortedBids.length; i++) { final double prevTotal = i > 0 ? _bidTotals[_bidTotals.length - 1] : 0; final Ask bid = sortedBids[i]; - _bidTotals.add( - prevTotal + (bid.maxvolume.toDouble() * double.parse(bid.price))); + _bidTotals.add(prevTotal + (bid.maxvolume.toDouble())); } - _maxAmount = max( + double _maxAmount = max( _askTotals.isNotEmpty ? _askTotals[_askTotals.length - 1] : 0, _bidTotals.isNotEmpty ? _bidTotals[_bidTotals.length - 1] : 0, ); diff --git a/lib/screens/markets/order_book_table.dart b/lib/screens/markets/order_book_table.dart index b947b2802..c2abbe09d 100644 --- a/lib/screens/markets/order_book_table.dart +++ b/lib/screens/markets/order_book_table.dart @@ -99,7 +99,7 @@ class _OrderBookTableState extends State { alignment: Alignment.centerRight, child: Text( AppLocalizations.of(context) - .ordersTableTotal(orderBookProvider.activePair.sell.abbr), + .ordersTableAmount(orderBookProvider.activePair.buy.abbr), maxLines: 1, style: const TextStyle(fontSize: 14), ), @@ -111,13 +111,13 @@ class _OrderBookTableState extends State { List _buildBidsList() { final List _sortedBids = List.from(widget.sortedBids); final List _bidsList = []; - double _bidTotal = 0; for (int i = 0; i < _sortedBids.length; i++) { final Ask bid = _sortedBids[i]; - final double _bidVolume = - bid.maxvolume.toDouble() * double.parse(bid.price); - _bidTotal += _bidVolume; + + final double _bidVolume = bid.maxvolume.toDouble(); + + final double convertedVolume = _bidVolume / bid.priceRat.toDouble(); _bidsList.add(TableRow( children: [ @@ -185,7 +185,7 @@ class _OrderBookTableState extends State { alignment: Alignment.centerRight, padding: const EdgeInsets.only(right: 4), child: Text( - formatPrice(_bidTotal.toString()), + formatPrice(convertedVolume.toString()), maxLines: 1, style: TextStyle( color: Theme.of(context) @@ -225,11 +225,11 @@ class _OrderBookTableState extends State { List _buildAsksList() { final List _sortedAsks = widget.sortedAsks; List _asksList = []; - double _askTotal = 0; for (int i = 0; i < _sortedAsks.length; i++) { final Ask ask = _sortedAsks[i]; - _askTotal += ask.maxvolume.toDouble(); + final convertedVolume = + ask.maxvolume.toDouble() * ask.priceRat.toDouble(); _asksList.add(TableRow( children: [ @@ -297,7 +297,7 @@ class _OrderBookTableState extends State { alignment: Alignment.centerRight, padding: const EdgeInsets.only(right: 4), child: Text( - formatPrice(_askTotal.toString()), + formatPrice(convertedVolume.toString()), maxLines: 1, style: TextStyle( color: Theme.of(context)