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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
| import 'package:flutter/material.dart';
import '../index.dart';
class TagsListWidget extends StatelessWidget { final Function(List<String> keys)? onTap;
final List<KeyValueModel<AttributeModel>> itemList;
final List<String> keys;
final double? width;
final double? height;
final Color? textColor;
final Color? textSelectedColor;
final double? textSize;
final FontWeight? textWeight;
final Color? bgColor;
final Color? bgSelectedColor;
final double? borderRadius;
final double? spacing;
final double? runSpacing;
final bool? isCircular;
final double? size;
TagsListWidget({ Key? key, this.onTap, required this.itemList, required this.keys, Color? bgColor, Color? bgSelectedColor, Color? textColor, Color? textSelectedColor, this.spacing, this.runSpacing, this.width = 50, this.height = 30, this.borderRadius = 3, this.textSize, this.textWeight, this.isCircular = false, this.size, }) : bgColor = bgColor ?? AppColors.surfaceVariant, bgSelectedColor = bgSelectedColor ?? AppColors.primary, textColor = textColor ?? AppColors.secondary, textSelectedColor = textSelectedColor ?? AppColors.onPrimary, super(key: key);
@override Widget build(BuildContext context) { return <Widget>[ for (var item in itemList) SizedBox( width: size ?? width, height: size ?? height, child: TextWidget.body2( item.value.name ?? "", color: keys.hasValue(item.key) == true ? textSelectedColor : textColor, textAlign: TextAlign.center, weight: textWeight ?? FontWeight.bold, size: textSize, ) .center() .decorated( color: keys.hasValue(item.key) == true ? bgSelectedColor : bgColor, borderRadius: BorderRadius.circular( isCircular == true ? size ?? 24 : borderRadius ?? 3), ) .onTap(() { if (keys.hasValue(item.key)) { keys.remove(item.key); } else { keys.add(item.key); } onTap?.call(keys); }), ) ].toWrap( spacing: spacing ?? AppSpace.listItem, runSpacing: runSpacing ?? AppSpace.listRow, ); } }
|