GeekyAnts / GaugesFlutter

A gauge package for Flutter that displays progress and can be customized for appearance and behavior.
https://pub.dev/packages/geekyants_flutter_gauges
MIT License
67 stars 15 forks source link

Double precision issue on dynamic min-max value #255

Open mqhamdam opened 7 months ago

mqhamdam commented 7 months ago

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 commented 7 months ago

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

mqhamdam commented 7 months ago

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
 )