Closed b-stud closed 5 years ago
Hi @b-stud, Thanks for your report.
Actually, I don't know what's wrong (in your case). The extension working well in my (Advan & Alcatel phones) marshmallow OS phones. Because I am creating this extension to fulfill my mobile app project too. And the application running wells, AFAIK my users using marshmallow OS too (internal company app).
The error is thrown by the following code execution:
FlutterMoneyFormatter._getOutput(package:flutter_money_formatter/src/flutter_money_formatter_base.dart:91:18)
Based on the error message above, the problem raised when searching position of decimal/precision separator char. But, I am not sure why the index returning -1
on your S9+.
I will do some investigation to solve this problem.
P.S: Oh, can you give me some little pieces of your code to reproduce the error? Because your sample case is still running well on my demo apps (tested with real device).
Hi @b-stud, Thanks for your report.
Actually, I don't know what's wrong (in your case). The extension working well in my (Advan & Alcatel phones) marshmallow OS phones. Because I am creating this extension to fulfill my mobile app project too. And the application running wells, AFAIK my users using marshmallow OS too (internal company app).
The error is thrown by the following code execution:
FlutterMoneyFormatter._getOutput(package:flutter_money_formatter/src/flutter_money_formatter_base.dart:91:18)
Based on the error message above, the problem raised when searching position of decimal/precision separator char. But, I am not sure why the index returning
-1
on your S9+.I will do some investigation to solve this problem.
P.S: Oh, can you give me some little pieces of your code to reproduce the error? Because your sample case is still running well on my demo apps (tested with real device).
For sure, I'm using the EventBrite Http API to get a price and a currency, I wrap everything on an Event class as below. Of course I debugged these values (price and currency) to ensure everything is as expected, which is the case, moreover, as it only occurs on some devices, I don't think the problem comes from here.
class Event {
...
final double price;
final String currency;
...
Event({
...
@required this.price,
@required this.currency,
...
});
}
// I'm using the eventbrite API
static Event _parseEventData(Map<String, dynamic> eventData, Position userPosition) {
return (Event(
...
price: eventData['ticket_availability']['minimum_ticket_price']['value'] / 100,
currency: eventData['ticket_availability']['minimum_ticket_price']['currency'],
...
));
}
Map<String, dynamic> eventRaw = await callAPI(parameters, _getEventDetailsUri);
core.Event event = _parseEventData(eventRaw);
FlutterMoneyFormatter(amount: event.price, settings: MoneyFormatterSettings(symbol: event.currency))
.output
.symbolOnRight))
Hi @b-stud, Since I don't have S9+ device, so what I can do is only testing it on emulator (oreo OS as used by S9+). But, I still have no clue about this problem, so I can't update this solution to the pub.dartlang.org nor to this repository.
So here are my quick fix, solution:
_getOutput()
method from flutter_money_formatter_base.dart
file which located on lib/src/
directory, with the syntaxes on below:example
directory and install it to your phone.MoneyFormatterOutput _getOutput() {
_utilities = _Utilities(amount: this.amount, settings: this.settings);
String _urs = _utilities.refineSeparator;
int _decSepCharPos = _urs.indexOf(this.settings.decimalSeparator);
return MoneyFormatterOutput(
nonSymbol: _urs,
symbolOnLeft: '${this.settings.symbol}${_utilities.spacer}$_urs',
symbolOnRight: '$_urs${_utilities.spacer}${this.settings.symbol}',
compactNonSymbol: _compactNonSymbol,
compactSymbolOnLeft:
'${this.settings.symbol}${_utilities.spacer}$_compactNonSymbol',
compactSymbolOnRight:
'$_compactNonSymbol${_utilities.spacer}${this.settings.symbol}',
fractionDigitsOnly:
_urs.substring((-1 == _decSepCharPos ? 0 : _decSepCharPos + 1)),
withoutFractionDigits:
_urs.substring(0, -1 == _decSepCharPos ? _urs.length - 1 : _decSepCharPos)
);
}
Since I can't test it on S9+ device, would you like to test it for me? And please let me know the result.
P.S:
I think this quick solution will make another problem when you fetch the value from fractionDigitsOnly
and withoutFractionDigits
.
Hi @fadhly-permata I just forked your repository and replaced the _getOutput
method with the one you wrote above, it definitely does work, at least, the error concerning the range error is not present anymore.
Concerning the potential problems with fractionDigitsOnly
and withoutFractionDigits
I'm not using them so I'm not sure if it created another bug, I can try something if you wish.
Thank you for your reactivity!
Hi @b-stud, I've released the update for this issue on https://pub.dev Thanks
Hello @fadhly-permata, thank you so much for your work, it's working perfectly now!
Describe the bug Hello, I'm facing an issue when I try to execute this simple instruction
Result:
Important note: This error does not occur on the emulator, it does only concern real devices (in my case, a S9+)
To Reproduce Steps to reproduce the behavior: Just execute the instruction above on a real device
Additional context The error is thrown by the following code execution:
Note: I have of course added the 'intl: ^0.15.8' dependency