[fix] transparent svgs (#3213)

* fix: transparent emojis

* chore: enhance documentation
This commit is contained in:
Alex Wallen 2023-08-15 15:14:22 -07:00 committed by GitHub
parent 29431b3038
commit f994f50ef9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 7 deletions

View File

@ -86,6 +86,7 @@ class SidebarUser extends StatelessWidget {
backgroundColor: Colors.transparent,
child: FlowySvg(
FlowySvgData('emoji/$iconUrl'),
blendMode: null,
),
),
),

View File

@ -318,6 +318,7 @@ class _CurrentIcon extends StatelessWidget {
child: FlowySvg(
FlowySvgData('emoji/$iconUrl'),
size: _iconSize,
blendMode: null,
),
),
),
@ -388,7 +389,11 @@ class IconOption extends StatelessWidget {
borderRadius: Corners.s6Border,
hoverColor: Theme.of(context).colorScheme.tertiaryContainer,
onTap: () => setIcon(iconUrl),
child: FlowySvg(emoji, size: _iconSize),
child: FlowySvg(
emoji,
size: _iconSize,
blendMode: null,
),
);
}
}

View File

@ -32,14 +32,19 @@ class FlowySvg extends StatelessWidget {
/// The size of the svg
final Size? size;
/// The color of the svg
/// The color of the svg.
///
/// This property will not be applied to the underlying svg widget if the
/// blend mode is null, but the blend mode defaults to [BlendMode.srcIn]
/// if it is not explicitly set to null.
final Color? color;
/// If true a color filter is applied to the SVG, otherwise not applied.
/// The blend mode applied to the svg.
///
/// Defaults to true
///
final BlendMode blendMode;
/// If the blend mode is null then the icon color will not be applied.
/// Set both the icon color and blendMode in order to apply color to the
/// svg widget.
final BlendMode? blendMode;
@override
Widget build(BuildContext context) {
@ -48,7 +53,11 @@ class FlowySvg extends StatelessWidget {
final child = SvgPicture.asset(
_normalized(),
colorFilter:
iconColor != null ? ColorFilter.mode(iconColor, blendMode)
iconColor != null && blendMode != null
? ColorFilter.mode(
iconColor,
blendMode!,
)
: null,
);