44
55import 'package:jaspr/jaspr.dart' ;
66
7+ import '../util.dart' ;
8+ import 'material_icon.dart' ;
9+
710/// A set of Material Design-like chips for configuration.
811class ChipSet extends StatelessComponent {
912 const ChipSet (this .chips, {this .resettable = false });
@@ -50,32 +53,25 @@ class InfoChip extends StatelessComponent {
5053 final chipClasses = ['chip' , 'info-chip' , ...? classes];
5154
5255 return div (
53- classes: chipClasses.join ( ' ' ) ,
56+ classes: chipClasses.toClasses ,
5457 attributes: attributes,
5558 [
56- if (icon != null )
57- span (
58- classes: 'material-symbols chip-icon' ,
59- attributes: {
60- 'aria-hidden' : 'true' ,
61- if (title != null ) 'title' : title! ,
62- },
63- [text (icon! )],
64- )
65- else if (iconPath != null )
59+ if (icon case final icon? )
60+ MaterialIcon (icon, title: title, classes: ['chip-icon' ])
61+ else if (iconPath case final iconPath? )
6662 svg (
6763 classes: 'chip-icon' ,
6864 width: iconSize.px,
6965 height: iconSize.px,
7066 viewBox: iconViewBox,
7167 attributes: {
7268 'aria-hidden' : 'true' ,
73- if (title != null ) 'title' : title! ,
69+ 'title' : ? title,
7470 },
7571 [
7672 Component .element (
7773 tag: 'path' ,
78- attributes: {'d' : iconPath! },
74+ attributes: {'d' : iconPath},
7975 ),
8076 ],
8177 ),
@@ -117,7 +113,7 @@ class FilterChip extends StatelessComponent {
117113 'data-filter' : dataFilter,
118114 'role' : 'checkbox' ,
119115 'aria-checked' : 'false' ,
120- if (ariaLabel != null ) 'aria-label' : ariaLabel! ,
116+ 'aria-label' : ? ariaLabel,
121117 },
122118 [
123119 if (showCheckIcon)
@@ -139,13 +135,9 @@ class FilterChip extends StatelessComponent {
139135 ),
140136 ],
141137 )
142- else if (icon != null )
143- span (
144- classes: 'material-symbols chip-icon leading-icon' ,
145- attributes: {'aria-hidden' : 'true' },
146- [text (icon! )],
147- )
148- else if (iconPath != null )
138+ else if (icon case final icon? )
139+ MaterialIcon (icon, classes: ['chip-icon' , 'leading-icon' ])
140+ else if (iconPath case final iconPath? )
149141 svg (
150142 classes: 'chip-icon leading-icon' ,
151143 width: iconSize.px,
@@ -155,7 +147,7 @@ class FilterChip extends StatelessComponent {
155147 [
156148 Component .element (
157149 tag: 'path' ,
158- attributes: {'d' : iconPath! },
150+ attributes: {'d' : iconPath},
159151 ),
160152 ],
161153 ),
@@ -190,7 +182,7 @@ class SelectChip extends StatelessComponent {
190182 classes: 'chip select-chip' ,
191183 attributes: {
192184 'data-menu' : menuId,
193- if (dataTitle != null ) 'data-title' : dataTitle! ,
185+ 'data-title' : ? dataTitle,
194186 'aria-controls' : menuId,
195187 'aria-expanded' : 'false' ,
196188 },
@@ -261,13 +253,9 @@ class SelectMenuItem extends StatelessComponent {
261253 'aria-selected' : isSelected.toString (),
262254 },
263255 [
264- if (icon != null )
265- span (
266- classes: 'material-symbols' ,
267- attributes: {'aria-hidden' : 'true' },
268- [text (icon! )],
269- )
270- else if (iconPath != null )
256+ if (icon case final icon? )
257+ MaterialIcon (icon)
258+ else if (iconPath case final iconPath? )
271259 svg (
272260 classes: 'menu-icon' ,
273261 width: iconSize.px,
@@ -277,7 +265,7 @@ class SelectMenuItem extends StatelessComponent {
277265 [
278266 Component .element (
279267 tag: 'path' ,
280- attributes: {'d' : iconPath! },
268+ attributes: {'d' : iconPath},
281269 ),
282270 ],
283271 ),
0 commit comments