getPercentToPanelPosition method

double getPercentToPanelPosition(
  1. double percent, {
  2. bool forDismissed = false,
})

Get Panel's height between PanelSize.closedHeight and PanelSize.expandedHeight, given specific percent between 0.0 and 1.0.

If forDismissed is true, the calculation is done from 0.0 to PanelSize.expandedHeight, rather than from PanelSize.closedHeight.

e.g.,

PanelSize.closedHeight = 0.25

PanelSize.expandedHeight = 0.75

If you want to get 25% of panel's height, then pass '0.25' as parameter, you will get '0.375'.

If you want to get 100% of panel's height, then pass '1.00' as parameter, you will get '0.75'.

Implementation

double getPercentToPanelPosition(double percent,
    {bool forDismissed = false}) {
  double min = 0.0;

  if (!forDismissed) min = panel!._metadata.closedHeight;

  double max = panel!._metadata.expandedHeight;

  double value = ((percent * (max - min)) + min);

  return (double.parse(value.toStringAsFixed(5)));
}