forked from firka/flutter
Update icon tree shaker to allow system font fallback (#147202)
Fixes https://github.com/flutter/flutter/issues/147189
This allows const `IconData` to fallback to the system font if `fontFamily` is not provided.
A similar non-fatal error occurs when IconData specifies a font that is not included in the manifest, so I modeled after that error message:
b4121a1867/packages/flutter_tools/lib/src/build_system/targets/icon_tree_shaker.dart (L122)
This commit is contained in:
@@ -327,15 +327,25 @@ class IconTreeShaker {
|
||||
final Object? package = iconDataMap['fontPackage'];
|
||||
final Object? fontFamily = iconDataMap['fontFamily'];
|
||||
final Object? codePoint = iconDataMap['codePoint'];
|
||||
if ((package ?? '') is! String || // Null is ok here.
|
||||
fontFamily is! String ||
|
||||
if ((package ?? '') is! String ||
|
||||
(fontFamily ?? '') is! String ||
|
||||
codePoint is! num) {
|
||||
throw IconTreeShakerException._(
|
||||
'Invalid ConstFinder result. Expected "fontPackage" to be a String, '
|
||||
'"fontFamily" to be a String, and "codePoint" to be an int, '
|
||||
'got: $iconDataMap.');
|
||||
}
|
||||
final String family = fontFamily;
|
||||
if (fontFamily == null) {
|
||||
_logger.printTrace(
|
||||
'Expected to find fontFamily for constant IconData with codepoint: '
|
||||
'$codePoint, but found fontFamily: $fontFamily. This usually means '
|
||||
'you are relying on the system font. Alternatively, font families in '
|
||||
'an IconData class can be provided in the assets section of your '
|
||||
'pubspec.yaml, or you are missing "uses-material-design: true".',
|
||||
);
|
||||
continue;
|
||||
}
|
||||
final String family = fontFamily as String;
|
||||
final String key = package == null
|
||||
? family
|
||||
: 'packages/$package/$family';
|
||||
|
||||
Reference in New Issue
Block a user