restored icon font tree shaking

This commit is contained in:
Thibault Deckers 2023-12-20 23:13:09 +01:00
parent ae5c2f795e
commit 372e5e75c9

View file

@ -36,7 +36,8 @@ class AIcons {
// as of Flutter v3.16.3, // as of Flutter v3.16.3,
// `label_important_outlined` matches text direction but is filled // `label_important_outlined` matches text direction but is filled
// `label_important_outline` is outlined but does not match text direction // `label_important_outline` is outlined but does not match text direction
static final important = Icons.label_important_outline.copyWith(matchTextDirection: true); static const important = IconData(labelImportantOutlineCodePoint, fontFamily: materialIconsFontFamily, matchTextDirection: true);
static const language = Icons.translate_outlined; static const language = Icons.translate_outlined;
static const location = Icons.place_outlined; static const location = Icons.place_outlined;
static const locationUnlocated = Icons.location_off_outlined; static const locationUnlocated = Icons.location_off_outlined;
@ -184,18 +185,9 @@ class AIcons {
static final github = MdiIcons.github; static final github = MdiIcons.github;
static final legal = MdiIcons.scaleBalance; static final legal = MdiIcons.scaleBalance;
}
extension ExtraIconData on IconData { // Material Icons references to make constant instances of `IconData`
IconData copyWith({ // as non-constant instances of `IconData` prevent icon font tree shaking
bool? matchTextDirection, static const labelImportantOutlineCodePoint = 0xe362;
}) { static const materialIconsFontFamily = 'MaterialIcons';
return IconData(
codePoint,
fontFamily: fontFamily,
fontPackage: fontPackage,
matchTextDirection: matchTextDirection ?? this.matchTextDirection,
fontFamilyFallback: fontFamilyFallback,
);
}
} }