Skip to content

Commit cd3d0b2

Browse files
Add shadows property
1 parent 32beff2 commit cd3d0b2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/src/fa_icon.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import 'package:flutter/foundation.dart';
56
import 'package:flutter/rendering.dart';
67
import 'package:flutter/widgets.dart';
78

@@ -26,6 +27,7 @@ class FaIcon extends StatelessWidget {
2627
this.color,
2728
this.semanticLabel,
2829
this.textDirection,
30+
this.shadows,
2931
}) : super(key: key);
3032

3133
/// The icon to display. Available icons are listed in [FontAwesomeIcons].
@@ -102,6 +104,17 @@ class FaIcon extends StatelessWidget {
102104
/// specified, either directly using this property or using [Directionality].
103105
final TextDirection? textDirection;
104106

107+
/// A list of [Shadow]s that will be painted underneath the icon.
108+
///
109+
/// Multiple shadows are supported to replicate lighting from multiple light
110+
/// sources.
111+
///
112+
/// Shadows must be in the same order for [Icon] to be considered as
113+
/// equivalent as order produces differing transparency.
114+
///
115+
/// Defaults to the nearest [IconTheme]'s [IconThemeData.shadows].
116+
final List<Shadow>? shadows;
117+
105118
@override
106119
Widget build(BuildContext context) {
107120
assert(this.textDirection != null || debugCheckHasDirectionality(context));
@@ -111,6 +124,7 @@ class FaIcon extends StatelessWidget {
111124
final IconThemeData iconTheme = IconTheme.of(context);
112125

113126
final double? iconSize = size ?? iconTheme.size;
127+
final List<Shadow>? iconShadows = shadows ?? iconTheme.shadows;
114128

115129
if (icon == null) {
116130
return Semantics(
@@ -138,6 +152,7 @@ class FaIcon extends StatelessWidget {
138152
fontSize: iconSize,
139153
fontFamily: icon!.fontFamily,
140154
package: icon!.fontPackage,
155+
shadows: iconShadows,
141156
),
142157
),
143158
);
@@ -172,5 +187,7 @@ class FaIcon extends StatelessWidget {
172187
IconDataProperty('icon', icon, ifNull: '<empty>', showName: false));
173188
properties.add(DoubleProperty('size', size, defaultValue: null));
174189
properties.add(ColorProperty('color', color, defaultValue: null));
190+
properties
191+
.add(IterableProperty<Shadow>('shadows', shadows, defaultValue: null));
175192
}
176193
}

0 commit comments

Comments
 (0)