From fcbde08c02a20537c4a1ab86cd1b5ff6bc3cff9a Mon Sep 17 00:00:00 2001 From: Sumit Tiware Date: Wed, 8 May 2024 18:45:23 +0530 Subject: [PATCH] chors : add some border-decoration --- example/lib/sources/complete_form.dart | 2 ++ .../check_box/check_box_group.dart | 23 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/example/lib/sources/complete_form.dart b/example/lib/sources/complete_form.dart index 3c59f433f..d956918ab 100644 --- a/example/lib/sources/complete_form.dart +++ b/example/lib/sources/complete_form.dart @@ -407,6 +407,8 @@ class _CompleteFormState extends State { ), ), ], + selectedBorderRadius: BorderRadius.circular(8), + selectedColor: Colors.pink, ), ], ), diff --git a/lib/src/alippo_custom_form_components/check_box/check_box_group.dart b/lib/src/alippo_custom_form_components/check_box/check_box_group.dart index bde338960..bf0ffa0fc 100644 --- a/lib/src/alippo_custom_form_components/check_box/check_box_group.dart +++ b/lib/src/alippo_custom_form_components/check_box/check_box_group.dart @@ -4,10 +4,15 @@ import 'package:flutter_form_builder/flutter_form_builder.dart'; class CustomCheckBoxGroup extends FormBuilderFieldDecoration> { final List> options; + final BorderRadius selectedBorderRadius; + final Color selectedColor; + CustomCheckBoxGroup({ super.key, required super.name, required this.options, + required this.selectedBorderRadius, + required this.selectedColor, }) : super( builder: (FormFieldState?> field) { final state = field as _CustomCheckBoxGroupState; @@ -16,6 +21,8 @@ class CustomCheckBoxGroup extends FormBuilderFieldDecoration> { child: SingleChildScrollView( child: _CustomGroupedCheckBox( options: options, + selectedBorderRadius: selectedBorderRadius, + selectedColor: selectedColor, value: field.value ?? [], onChanged: (val) { field.didChange(val); @@ -40,6 +47,9 @@ class _CustomGroupedCheckBox extends StatelessWidget { final List value; final ValueChanged> onChanged; + final BorderRadius selectedBorderRadius; + final Color selectedColor; + final Axis direction; final double spacing; final bool expanded; @@ -53,6 +63,8 @@ class _CustomGroupedCheckBox extends StatelessWidget { this.direction = Axis.horizontal, this.spacing = 0.0, this.expanded = false, + required this.selectedBorderRadius, + required this.selectedColor, }); @override @@ -64,6 +76,8 @@ class _CustomGroupedCheckBox extends StatelessWidget { return Builder(builder: (context) { return SelectOptionsWrapper( isSelected: value.contains(option.value), + selectedBorderRadius: selectedBorderRadius, + selectedColor: selectedColor, child: InkWell( onTap: () { List selectedListItems = List.of(value); @@ -84,11 +98,15 @@ class _CustomGroupedCheckBox extends StatelessWidget { class SelectOptionsWrapper extends StatefulWidget { final bool isSelected; final Widget child; + final BorderRadius selectedBorderRadius; + final Color selectedColor; const SelectOptionsWrapper({ super.key, required this.isSelected, required this.child, + this.selectedBorderRadius = const BorderRadius.all(Radius.circular(4)), + this.selectedColor = Colors.red, }); @override @@ -103,9 +121,10 @@ class _SelectOptionsWrapperState extends State { padding: !widget.isSelected ? EdgeInsets.zero : const EdgeInsets.all(4), decoration: BoxDecoration( border: Border.all( - color: widget.isSelected ? Colors.red : Colors.grey, - width: 1.0, + color: widget.isSelected ? widget.selectedColor : Colors.grey, + width: 2.0, ), + borderRadius: widget.selectedBorderRadius, ), child: widget.child, );