Giter VIP home page Giter VIP logo

Comments (6)

fadhly-permata avatar fadhly-permata commented on September 17, 2024 1

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).

from flutter_money_formatter.

b-stud avatar b-stud commented on September 17, 2024

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))

from flutter_money_formatter.

fadhly-permata avatar fadhly-permata commented on September 17, 2024

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:

  1. Download (or fork) this project.
  2. Replace _getOutput() method from flutter_money_formatter_base.dart file which located on lib/src/ directory, with the syntaxes on below:
  3. Build and copy the APK from the 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.

from flutter_money_formatter.

b-stud avatar b-stud commented on September 17, 2024

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!

from flutter_money_formatter.

fadhly-permata avatar fadhly-permata commented on September 17, 2024

Hi @b-stud, I've released the update for this issue on https://pub.dev
Thanks

from flutter_money_formatter.

b-stud avatar b-stud commented on September 17, 2024

Hello @fadhly-permata, thank you so much for your work, it's working perfectly now!

from flutter_money_formatter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.