ResponsiveHeight function
double
ResponsiveHeight(
- BuildContext context,
- double containerHeight, {
- double? designScreenHeight = 792,
Implementation
double ResponsiveHeight(BuildContext context, double containerHeight,
{double? designScreenHeight = 792}) {
final screenHeight = MediaQuery.of(context).size.height;
// Set the reference screen height once
_referenceScreenHeight ??= designScreenHeight;
// Calculate the scaling factor
final scaleFactor = screenHeight / _referenceScreenHeight!;
// Calculate and return the responsive height
return containerHeight * scaleFactor;
}