Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flex parameter to MaxGap #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/src/widgets/gap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class MaxGap extends StatelessWidget {
Key? key,
this.crossAxisExtent,
this.color,
this.flex = 1,
}) : super(key: key);

/// Creates a widget that takes, at most, the specified [mainAxisExtent] of
Expand All @@ -119,11 +120,13 @@ class MaxGap extends StatelessWidget {
double mainAxisExtent, {
Key? key,
Color? color,
int? flex,
}) : this(
mainAxisExtent,
key: key,
crossAxisExtent: double.infinity,
color: color,
flex: flex,
);

/// The amount of space this widget takes in the direction of the parent.
Expand All @@ -148,9 +151,19 @@ class MaxGap extends StatelessWidget {
/// The color used to fill the gap.
final Color? color;

/// The flex factor to use in determining how much space to take up.
///
/// The amount of space the [MaxGap] can occupy in the main axis is determined
/// by dividing the free space proportionately, after placing the inflexible
/// children, according to the flex factors of the flexible children.
///
/// Defaults to one.
final int flex;

@override
Widget build(BuildContext context) {
return Flexible(
flex: flex,
child: _RawGap(
mainAxisExtent,
crossAxisExtent: crossAxisExtent,
Expand Down