mirror of
https://github.com/Iconica-Development/flutter_input_library.git
synced 2025-05-18 17:03:45 +02:00
feat: add option for spacing between radio items
This commit is contained in:
parent
5bee01e304
commit
0da6ba35f2
4 changed files with 17 additions and 3 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
## 3.7.0
|
||||||
|
|
||||||
|
* Added a 16 pixel padding between the `FlutterFormInputRadioPicker` items that is customizable with the `itemSpacing` parameter.
|
||||||
|
|
||||||
## 3.6.0
|
## 3.6.0
|
||||||
* Added style parameter to `FlutterFormInputMultiLine`
|
* Added style parameter to `FlutterFormInputMultiLine`
|
||||||
* Upgrade flutter_iconica_analysis to 7.0.0
|
* Upgrade flutter_iconica_analysis to 7.0.0
|
||||||
|
|
|
@ -14,18 +14,21 @@ class FlutterFormInputRadioPicker extends StatelessWidget {
|
||||||
this.onSaved,
|
this.onSaved,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
this.initialValue,
|
this.initialValue,
|
||||||
|
this.itemSpacing = 16.0,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Function(RadioItem?)? onSaved;
|
final Function(RadioItem?)? onSaved;
|
||||||
final String? initialValue;
|
final String? initialValue;
|
||||||
final Function(RadioItem?)? onChanged;
|
final Function(RadioItem?)? onChanged;
|
||||||
final List<RadioItem> items;
|
final List<RadioItem> items;
|
||||||
|
final double itemSpacing;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => RadioPickerFormField(
|
Widget build(BuildContext context) => RadioPickerFormField(
|
||||||
onSaved: (value) => onSaved?.call(value),
|
onSaved: (value) => onSaved?.call(value),
|
||||||
onChanged: (value) => onChanged?.call(value),
|
onChanged: (value) => onChanged?.call(value),
|
||||||
initialValue: items.firstWhereOrNull((i) => i.value == initialValue),
|
initialValue: items.firstWhereOrNull((i) => i.value == initialValue),
|
||||||
|
itemSpacing: itemSpacing,
|
||||||
items: items,
|
items: items,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -34,6 +37,7 @@ class RadioPickerFormField extends FormField<RadioItem?> {
|
||||||
RadioPickerFormField({
|
RadioPickerFormField({
|
||||||
required FormFieldSetter<RadioItem> super.onSaved,
|
required FormFieldSetter<RadioItem> super.onSaved,
|
||||||
required List<RadioItem> items,
|
required List<RadioItem> items,
|
||||||
|
required double itemSpacing,
|
||||||
void Function(RadioItem value)? onChanged,
|
void Function(RadioItem value)? onChanged,
|
||||||
super.initialValue,
|
super.initialValue,
|
||||||
super.key,
|
super.key,
|
||||||
|
@ -46,6 +50,7 @@ class RadioPickerFormField extends FormField<RadioItem?> {
|
||||||
},
|
},
|
||||||
items: items,
|
items: items,
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
|
itemSpacing: itemSpacing,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ class RadioPicker extends StatefulWidget {
|
||||||
const RadioPicker({
|
const RadioPicker({
|
||||||
required this.onChanged,
|
required this.onChanged,
|
||||||
required this.items,
|
required this.items,
|
||||||
|
this.itemSpacing = 16.0,
|
||||||
this.initialValue,
|
this.initialValue,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
@ -13,6 +14,9 @@ class RadioPicker extends StatefulWidget {
|
||||||
final Function(RadioItem) onChanged;
|
final Function(RadioItem) onChanged;
|
||||||
final List<RadioItem> items;
|
final List<RadioItem> items;
|
||||||
|
|
||||||
|
/// The spacing between each item.
|
||||||
|
final double itemSpacing;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<RadioPicker> createState() => _RadioPickerState();
|
State<RadioPicker> createState() => _RadioPickerState();
|
||||||
}
|
}
|
||||||
|
@ -42,6 +46,9 @@ class _RadioPickerState extends State<RadioPicker> {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
if (widget.items.last != item) ...[
|
||||||
|
SizedBox(width: widget.itemSpacing),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: flutter_input_library
|
name: flutter_input_library
|
||||||
description: A new Flutter package project.
|
description: A new Flutter package project.
|
||||||
version: 3.6.0
|
version: 3.7.0
|
||||||
repository: https://github.com/Iconica-Development/flutter_input_library
|
repository: https://github.com/Iconica-Development/flutter_input_library
|
||||||
|
|
||||||
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub
|
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub
|
||||||
|
@ -22,5 +22,3 @@ dev_dependencies:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/Iconica-Development/flutter_iconica_analysis
|
url: https://github.com/Iconica-Development/flutter_iconica_analysis
|
||||||
ref: 7.0.0
|
ref: 7.0.0
|
||||||
|
|
||||||
flutter:
|
|
||||||
|
|
Loading…
Reference in a new issue