'FLUTTER: Responsive Widgets with Zoom
FLUTTER: How do I make my widgets (which use fontSize, height and width) responsive to device zoom? I always use MediaQuery.of(context).size for different phones resolutions, but what about when the problem is zooming?
Picture without Zoom

Picture with Zoom

Solution 1:[1]
Aside from MediaQuery, you can use LayoutBuilder to check the parent widget's dimension and be able to adjust the child widget's dimension as needed.
LayoutBuilder(builder: (context, constraints) {
debugPrint('Max height: ${constraints.maxHeight}, max width: ${constraints.maxWidth}');
return Container(); // create function here to adapt to the parent widget's constraints
}),
Overflow errors happen when the Widget displayed on screen exceeds its parent widget's dimension. What you can do here for the child widgets to adapt with the change in dimension is by setting Constraints - this helps set a minimum and max dimensions for the widget. You can check this guide for more details.
ConstrainedBox(
constraints: const BoxConstraints(
minWidth: 70,
minHeight: 70,
maxWidth: 150,
maxHeight: 150,
),
child: YourButton(),
),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Omatt |
