'How to correctly make a large limited distance between widgets Flutter
Need help. Tell me how to correctly add a limited empty space (as in the screenshot) between the 2500 widget and the buttons that are at the very bottom. It is necessary to add exactly the limited distance so that I can use the SingleChildScrollView widget. And so that on different screen sizes this empty distance changes according to the screens of the device. I will be grateful for help.
Widget _child() => Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Column(
children: [
const SizedBox(height: 121.0),
BackStepWidget(
text: 'Balance: $coins',
textStyle: constants.Styles.largeHeavyTextStyleWhite,
),
const Text(
'Buy JoinCoins',
style: constants.Styles.bigHeavyTextStyleWhite,
),
const Image(
image: AssetImage('assets/images/image.png'),
),
const CoinsCounterWidget(),
],
),
);
Solution 1:[1]
For limited height based on screen, you need to get the size of the screen, you can use MediaQuery but I prefer using LayoutBuilder.
Use LayoutBuilder as top/first widget and use its constraints to get size. I am using on body to avoid mixing others spaces,
home: Scaffold(
body: LayoutBuilder(
builder: (context, constraints) {
return Column(
children: [
Text("top items"),
SizedBox(height: constraints.maxHeight*.2,) // 20% height
// others widgets
],
);
},
),
)
More about LayoutBuilder.
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 | Yeasin Sheikh |

