From 35c1e201b0373e051c22d7b9a65d79695c08200d Mon Sep 17 00:00:00 2001 From: Jimmy Date: Mon, 29 Apr 2024 09:19:11 +0200 Subject: [PATCH] Add auto layout --- lib/src/form_builder_field.dart | 2 +- lib/src/widgets/grouped_checkbox.dart | 7 ++++++- lib/src/widgets/grouped_radio.dart | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/src/form_builder_field.dart b/lib/src/form_builder_field.dart index 81bfea8c0..e73d6f365 100644 --- a/lib/src/form_builder_field.dart +++ b/lib/src/form_builder_field.dart @@ -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 } diff --git a/lib/src/widgets/grouped_checkbox.dart b/lib/src/widgets/grouped_checkbox.dart index 32f354244..992950d5a 100644 --- a/lib/src/widgets/grouped_checkbox.dart +++ b/lib/src/widgets/grouped_checkbox.dart @@ -224,7 +224,12 @@ class GroupedCheckbox 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( diff --git a/lib/src/widgets/grouped_radio.dart b/lib/src/widgets/grouped_radio.dart index c1ada2cec..a26ac4571 100644 --- a/lib/src/widgets/grouped_radio.dart +++ b/lib/src/widgets/grouped_radio.dart @@ -218,6 +218,11 @@ class _GroupedRadioState extends State> { } switch (widget.orientation) { + case OptionsOrientation.auto: + return OverflowBar( + alignment: MainAxisAlignment.spaceEvenly, + children: widgetList, + ); case OptionsOrientation.vertical: return SingleChildScrollView( scrollDirection: Axis.vertical,