Skip to content

Add fit and flex controls to MaxGap and refine gap layout behavior#29

Open
Sadoge wants to merge 2 commits into
letsar:masterfrom
Sadoge:master
Open

Add fit and flex controls to MaxGap and refine gap layout behavior#29
Sadoge wants to merge 2 commits into
letsar:masterfrom
Sadoge:master

Conversation

@Sadoge
Copy link
Copy Markdown

@Sadoge Sadoge commented Mar 30, 2026

Improve gap cross-axis handling and add fit/flex controls to MaxGap

Summary

This PR improves Gap/MaxGap layout behavior and expands MaxGap's Flex configurability without breaking existing usage.

It includes the earlier refactor around crossAxisExtent and MaxGap.fit, plus the follow-up change from issue #17 to add a configurable flex parameter to MaxGap.

Changes

  • Treat crossAxisExtent as 0 by default before constraints are applied.
  • Add fit to MaxGap so it can opt into FlexFit.tight.
  • Add flex to MaxGap, defaulting to 1 to preserve current behavior.
  • Forward both fit and flex to the internal Flexible.
  • Keep existing call sites like MaxGap(24) source-compatible.
  • Reuse Paint objects in RenderGap and RenderSliverGap.
  • Update docs and tests to reflect the current behavior.

Behavior

  • No breaking API changes.
  • Existing MaxGap behavior remains unchanged by default.
  • MaxGap now supports custom Flex distribution when multiple gaps are used together.
  • Gap and MaxGap continue to shrink correctly when constrained.

Tests

Added and updated tests covering:

  • default constructor behavior
  • zero cross-axis extent behavior
  • painting behavior for Gap and SliverGap
  • MaxGap.fit
  • MaxGap.flex forwarding
  • space distribution between multiple MaxGaps with different flex values
  • constrained MaxGap behavior
  • scrollable and sliver layout cases

Sadoge added 2 commits March 30, 2026 11:53
- Default crossAxisExtent to 0 instead of null in RenderGap.
- Add a fit parameter to MaxGap to support FlexFit.tight.
- Optimize painting by reusing Paint objects in RenderGap and RenderSliverGap.
- Update documentation and tests to reflect these changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant