fayaz07 / progress_dialog

A light weight library to easily manage a progress dialog with simple steps whenever you need to do it. You can easily show and hide it.

Home Page:https://fayaz07.github.io/progress_dialog/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Download progress decimal places pattern

fernando-s97 opened this issue · comments

Is your feature request related to a problem? Please describe.
I need to change the predefined progress text when using .
When displaying the ProgressDialogType.Download, I don't like the fact that that progress shows its complete value. For example:
1/100.0
1.3276872287/100.0
3.82738/100.0

I guess it would be nice to have some way to make it follow a pattern.

Describe the solution you'd like
Two parameters in the constructor to allow defining the decimal places of the current progress (progressDecimalPlaces) and max progress (maxProgressDecimalPlaces).

downloadDialog ??= ProgressDialog(
    context,
    type: ProgressDialogType.Download,
    progressDecimalPlaces: [int],
    maxProgressDecimalPlaces: [int],
  );

Some examples:
progressDecimalPlaces: 0 | maxProgressDecimalPlaces: 0 -> 4/100
progressDecimalPlaces: 0 | maxProgressDecimalPlaces: 2 -> 4/100.00
progressDecimalPlaces: 2 | maxProgressDecimalPlaces: 0 -> 4.25/100
progressDecimalPlaces: 2 | maxProgressDecimalPlaces: 2 -> 4.25/100.00

To allow the default user/dart double.toString() pass -1 as value:

downloadDialog ??= ProgressDialog(
    context,
    type: ProgressDialogType.Download,
    progressDecimalPlaces: -1,
    maxProgressDecimalPlaces: -1,
  );

This would result in the normal behaviour of the lib today: 1.3276872287/100.0

you can achieve that with something like this

doubleValue.toStringAsFixed(2)
progressDialog.update(down..: Double.parse(doubleValue.toStringAsFixed(2)));

This will correctly show the current progress, but not max progress. It will display something like xx.xx/100.0 - The max progress still displays 1 decimal place.

you should figure it out bro

I've figured out. It was just a tip to improve your package...

thanks @fernando-s97 I will surely update, due to busy schedule I wasn't able to look up on it