From 90e0d2f52be8c575be2b228111a85035130058df Mon Sep 17 00:00:00 2001 From: Faris Armoush Date: Tue, 15 Apr 2025 15:24:36 +0300 Subject: [PATCH] Extracted Chip into a private method. --- .../widgets/tag_chips_display_widget.dart | 55 ++++++++++--------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/lib/pages/spaces_management/space_model/widgets/tag_chips_display_widget.dart b/lib/pages/spaces_management/space_model/widgets/tag_chips_display_widget.dart index 1f75a047..200cd659 100644 --- a/lib/pages/spaces_management/space_model/widgets/tag_chips_display_widget.dart +++ b/lib/pages/spaces_management/space_model/widgets/tag_chips_display_widget.dart @@ -66,31 +66,7 @@ class TagChipDisplay extends StatelessWidget { spacing: 8, runSpacing: 8, children: [ - ..._groupedTags.entries.map((entry) { - return Chip( - avatar: SizedBox( - width: 24, - height: 24, - child: SvgPicture.asset( - entry.key.icon ?? 'assets/icons/gateway.svg', - fit: BoxFit.contain, - ), - ), - label: Text( - 'x${entry.value}', - style: context.textTheme.bodySmall!.copyWith( - color: ColorsManager.spaceColor, - ), - ), - backgroundColor: ColorsManager.whiteColors, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16), - side: const BorderSide( - color: ColorsManager.spaceColor, - ), - ), - ); - }), + ..._groupedTags.entries.map((entry) => _buildChip(context, entry)), EditChip( onTap: () => showDialog( context: context, @@ -124,6 +100,35 @@ class TagChipDisplay extends StatelessWidget { } } + Chip _buildChip( + BuildContext context, + MapEntry entry, + ) { + return Chip( + avatar: SizedBox( + width: 24, + height: 24, + child: SvgPicture.asset( + entry.key.icon ?? 'assets/icons/gateway.svg', + fit: BoxFit.contain, + ), + ), + label: Text( + '${entry.value}', + style: context.textTheme.bodySmall!.copyWith( + color: ColorsManager.spaceColor, + ), + ), + backgroundColor: ColorsManager.whiteColors, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + side: const BorderSide( + color: ColorsManager.spaceColor, + ), + ), + ); + } + Widget _buildAddDevicesButton(BuildContext context) { return TextButton( onPressed: () => showDialog(