Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double precision issue on dynamic min-max value #255

Open
mqhamdam opened this issue Jan 11, 2024 · 2 comments · Fixed by #269
Open

Double precision issue on dynamic min-max value #255

mqhamdam opened this issue Jan 11, 2024 · 2 comments · Fixed by #269
Assignees
Labels
bug Something isn't working Feature This is a new feature for the project

Comments

@mqhamdam
Copy link

Is your feature request related to a problem? Please describe.
Wanna Add Widget on Ruler (Using Custom Ruler not good, since have to calculate interval(steps by myself). When i change min max, i face with Double precision error. ex: 3.0 + 3.0 = 7. (just example or sometimes its like this: 7.942123212),

Describe the solution you'd like
There are some packages that offer to customize the label.

Widget buildLabel(double value, int index) => MyCustomLabel(...);

Personally for calculating double values I use decimal package. So im try to use that here. but cannot.

I don't think its that difficult to add such feature.
adding callback property in RulerStyle might be good solution. and if that callback is null, use default Widget.

@hasnentai
Copy link
Contributor

Hi, @mqhamdam Can you add a proper example so that we can recreate the issue and fix it?
cc : @Afroz-Shaikh

@hasnentai hasnentai added the bug Something isn't working label Jan 11, 2024
@mqhamdam
Copy link
Author

I fix the problem, but still think that it would be good to customize generated labels.

This is Screen Recording
https://github.com/GeekyAnts/GaugesFlutter/assets/56746482/6f1ec06d-b19b-4eaa-9269-7887182b64e0

from

LinearGauge(
         start: -50,
         end: state.savedDistance + 50,
 // other part
 )

to

LinearGauge(
       start: -50,
       end: (Decimal.parse(state.savedDistance.toStringAsFixed(2)) +
               Decimal.fromInt(50))
               .toDouble(),
       // other part
 )

@Afroz-Shaikh Afroz-Shaikh added the Feature This is a new feature for the project label Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Feature This is a new feature for the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants