1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| class ChoiceSingle<T extends Choice> extends ConsumerWidget { const ChoiceSingle({ super.key, required this.label, required this.value, required this.data, required this.onChanged, }); final String label; final T? value; final List<T> data; final void Function(T) onChanged;
@override Widget build(BuildContext context, WidgetRef ref) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(label), if (data.isEmpty) const Center(child: LoadingSmall()) else Center( child: ChipsChoice<T>.single( wrapped: true, value: value, onChanged: onChanged, choiceCheckmark: true, choiceStyle: C2ChipStyle.outlined( color: Colors.grey, selectedStyle: C2ChipStyle.filled( color: Theme.of(context).primaryColor, foregroundColor: Colors.white, borderRadius: const BorderRadius.all( Radius.circular(25), ), ), ), choiceItems: C2Choice.listFrom<T, T>( source: data, value: (index, item) => item, label: (index, item) => item.name, ), ), ), ], ); } }
|