converted to using expressions wherever possible in TagChipDisplay.

This commit is contained in:
Faris Armoush
2025-04-15 15:13:47 +03:00
parent be168aed93
commit f57348e5cd

View File

@ -38,6 +38,11 @@ class TagChipDisplay extends StatelessWidget {
super.key, super.key,
}); });
Map<ProductModel, int> get _groupedTags => TagHelper.groupTags([
...?spaceModel?.tags,
...?spaceModel?.subspaceModels?.expand((e) => e.tags ?? [])
]);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final hasTags = spaceModel?.tags?.isNotEmpty ?? false; final hasTags = spaceModel?.tags?.isNotEmpty ?? false;
@ -61,11 +66,8 @@ class TagChipDisplay extends StatelessWidget {
spacing: 8.0, spacing: 8.0,
runSpacing: 8.0, runSpacing: 8.0,
children: [ children: [
...TagHelper.groupTags([ ..._groupedTags.entries.map((entry) {
...?spaceModel?.tags, return Chip(
...?spaceModel?.subspaceModels?.expand((e) => e.tags ?? [])
]).entries.map(
(entry) => Chip(
avatar: SizedBox( avatar: SizedBox(
width: 24, width: 24,
height: 24, height: 24,
@ -87,10 +89,10 @@ class TagChipDisplay extends StatelessWidget {
color: ColorsManager.spaceColor, color: ColorsManager.spaceColor,
), ),
), ),
), );
), }),
EditChip( EditChip(
onTap: () => showDialog<bool>( onTap: () => showDialog<void>(
context: context, context: context,
builder: (context) => AssignTagModelsDialog( builder: (context) => AssignTagModelsDialog(
products: products, products: products,
@ -119,8 +121,7 @@ class TagChipDisplay extends StatelessWidget {
); );
} else { } else {
return TextButton( return TextButton(
onPressed: () { onPressed: () => showDialog<void>(
showDialog<void>(
context: context, context: context,
builder: (context) => AddDeviceTypeModelWidget( builder: (context) => AddDeviceTypeModelWidget(
products: products, products: products,
@ -133,8 +134,7 @@ class TagChipDisplay extends StatelessWidget {
otherSpaceModels: otherSpaceModels, otherSpaceModels: otherSpaceModels,
projectTags: projectTags, projectTags: projectTags,
), ),
); ),
},
style: TextButton.styleFrom( style: TextButton.styleFrom(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
), ),