RitickSaha / glassmorphism

Glassmorphic UI Package For Flutter || UI ||
https://pub.dev/packages/glassmorphism
Apache License 2.0
66 stars 26 forks source link

Make the height and width dynamically adjust with the content #6

Closed pratikbaid3 closed 3 years ago

pratikbaid3 commented 3 years ago

Currently, the height and width is a mandatory parameter which provides some constraints in terms of the responsiveness of the widget. Would it be possible to make these fit dynamically to the content within like the standard container does?

C0RALINA commented 3 years ago

Hi, I haven't figured out a way to do exactly that, but I use the following to change the container size dynamically based on the screen size:

final screenWidth = MediaQuery.of(context).size.width; final screenHeight = MediaQuery.of(context).size.height;

then:

width: screenWidth - 20, height: screenHeight - 245,

or

width: screenWidth / 2, height: screenHeight *0.9,

RitickSaha commented 3 years ago

Hi, I haven't figured out a way to do exactly that, but I use the following to change the container size dynamically based on the screen size:

final screenWidth = MediaQuery.of(context).size.width; final screenHeight = MediaQuery.of(context).size.height;

then:

width: screenWidth - 20, height: screenHeight - 245,

or

width: screenWidth / 2, height: screenHeight *0.9,

That’s s a great way to make your design response according to Device sizes. Because there is the use of custom painter in the package the widget requires a pre-defined size to render the canvas according to the size.

To Make the HIght and Width adjust dynamically you can use these widgets:

or you can use MediaQuery to understand the device size as @C0RALINA explains.

princeteck commented 3 years ago

Hi, I haven't figured out a way to do exactly that, but I use the following to change the container size dynamically based on the screen size: final screenWidth = MediaQuery.of(context).size.width; final screenHeight = MediaQuery.of(context).size.height; then: width: screenWidth - 20, height: screenHeight - 245, or width: screenWidth / 2, height: screenHeight *0.9,

That’s s a great way to make your design response according to Device sizes. Because there is the use of custom painter in the package the widget requires a pre-defined size to render the canvas according to the size.

To Make the HIght and Width adjust dynamically you can use these widgets:

* Flexible [GUIDE](https://api.flutter.dev/flutter/widgets/Flexible-class.html)

* Expanded [GUIDE](https://api.flutter.dev/flutter/widgets/Expanded-class.html)

* FittedBox [GUIDE](https://api.flutter.dev/flutter/widgets/FittedBox-class.html)

or you can use MediaQuery to understand the device size as @C0RALINA explains.

You have made the option as required due to which if we are not using those properties, we atleast needs to assign null value which doesn't make any sense.

RitickSaha commented 3 years ago

closes #7 You can now upgrade to glassmorphism: ^3.0.0 and use GlassmorphismFlexContainer to do this stuff easily.