Skip to content

Commit

Permalink
Merge pull request #1383 from Masadow/main
Browse files Browse the repository at this point in the history
Add OverflowBar layout for radios and checkboxes
  • Loading branch information
deandreamatias authored Apr 30, 2024
2 parents c12d30a + 35c1e20 commit 626bd43
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/src/form_builder_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_form_builder/src/extensions/autovalidatemode_extension.dart';

enum OptionsOrientation { horizontal, vertical, wrap }
enum OptionsOrientation { horizontal, vertical, wrap, auto }

enum ControlAffinity { leading, trailing }

Expand Down
7 changes: 6 additions & 1 deletion lib/src/widgets/grouped_checkbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,12 @@ class GroupedCheckbox<T> extends StatelessWidget {
widgetList.add(buildItem(i));
}
Widget finalWidget;
if (orientation == OptionsOrientation.vertical) {
if (orientation == OptionsOrientation.auto) {
finalWidget = OverflowBar(
alignment: MainAxisAlignment.spaceEvenly,
children: widgetList,
);
} else if (orientation == OptionsOrientation.vertical) {
finalWidget = SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
Expand Down
5 changes: 5 additions & 0 deletions lib/src/widgets/grouped_radio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ class _GroupedRadioState<T> extends State<GroupedRadio<T?>> {
}

switch (widget.orientation) {
case OptionsOrientation.auto:
return OverflowBar(
alignment: MainAxisAlignment.spaceEvenly,
children: widgetList,
);
case OptionsOrientation.vertical:
return SingleChildScrollView(
scrollDirection: Axis.vertical,
Expand Down

0 comments on commit 626bd43

Please sign in to comment.