gap
gap copied to clipboard
How to combine Gap with Expanded/Flexible widgets
Hello. I'm very familiar with the Expanded/Flexible widgets that help me a lot to position my widgets how I want in the Columns & Rows. But when I use them with Gap it doesn't seem to work as I would expect it.
Sample code
Column(
children: [
MaxGap(32),
Text("Some title"),
MaxGap(16),
Text("Some subtitle"),
Expanded(
child: PageView(
children: [
CarouselSlide(),
CarouselSlide(),
CarouselSlide(),
],
)
),
MaxGap(24),
TextButton(child: Text("A button")),
],
);
Expected outcome:
- The gaps between widgets don't exceed the value given to the MaxGap widget. While getting smaller if there is not enough space.
- The PageView (carousel in this example) expands and takes as much space as possible.
What I get:
For each MaxGap widget that I add the Expanded widget reduces its size to half.
How can I can use the Gap widget while still being able to utilize widgets like Expanded, Flexible or Spacer?