@@ -86,9 +86,10 @@ class Icon extends StatelessWidget {
86
86
this .semanticLabel,
87
87
this .textDirection,
88
88
this .applyTextScaling,
89
- }) : assert (fill == null || (0.0 <= fill && fill <= 1.0 )),
90
- assert (weight == null || (0.0 < weight)),
91
- assert (opticalSize == null || (0.0 < opticalSize));
89
+ this .blendMode,
90
+ }) : assert (fill == null || (0.0 <= fill && fill <= 1.0 )),
91
+ assert (weight == null || (0.0 < weight)),
92
+ assert (opticalSize == null || (0.0 < opticalSize));
92
93
93
94
/// The icon to display. The available icons are described in [Icons] .
94
95
///
@@ -247,6 +248,11 @@ class Icon extends StatelessWidget {
247
248
/// [IconThemeData.applyTextScaling] .
248
249
final bool ? applyTextScaling;
249
250
251
+ /// The [BlendMode] to apply to the foreground of the icon.
252
+ ///
253
+ /// Defaults to [BlendMode.srcOver]
254
+ final BlendMode ? blendMode;
255
+
250
256
@override
251
257
Widget build (BuildContext context) {
252
258
assert (this .textDirection != null || debugCheckHasDirectionality (context));
@@ -279,10 +285,18 @@ class Icon extends StatelessWidget {
279
285
}
280
286
281
287
final double iconOpacity = iconTheme.opacity ?? 1.0 ;
282
- Color iconColor = color ?? iconTheme.color! ;
288
+ Color ? iconColor = color ?? iconTheme.color! ;
289
+ Paint ? foreground;
283
290
if (iconOpacity != 1.0 ) {
284
291
iconColor = iconColor.withOpacity (iconColor.opacity * iconOpacity);
285
292
}
293
+ if (blendMode != null ) {
294
+ foreground = Paint ()
295
+ ..blendMode = blendMode!
296
+ ..color = iconColor;
297
+ // Cannot provide both a color and a foreground.
298
+ iconColor = null ;
299
+ }
286
300
287
301
final TextStyle fontStyle = TextStyle (
288
302
fontVariations: < FontVariation > [
@@ -298,8 +312,9 @@ class Icon extends StatelessWidget {
298
312
package: icon.fontPackage,
299
313
fontFamilyFallback: icon.fontFamilyFallback,
300
314
shadows: iconShadows,
301
- height: 1.0 , // Makes sure the font's body is vertically centered within the iconSize x iconSize square.
315
+ height: 1.0 , // Makes sure the font's body is vertically centered within the iconSize x iconSize square.
302
316
leadingDistribution: TextLeadingDistribution .even,
317
+ foreground: foreground,
303
318
);
304
319
305
320
Widget iconWidget = RichText (
0 commit comments