Skip to content

Commit 717f9de

Browse files
[flutter_tools] enable tree-shake-icons by default for non-web targets (flutter#56633)
Enable tree-shake-icons by default for non-web targets. Make missing fonts a status print
1 parent 7eff0a8 commit 717f9de

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

packages/flutter_tools/lib/src/build_system/targets/icon_tree_shaker.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import 'dart.dart';
2121
const String kIconTreeShakerFlag = 'TreeShakeIcons';
2222

2323
/// Whether icon font subsetting is enabled by default.
24-
const bool kIconTreeShakerEnabledDefault = false;
24+
const bool kIconTreeShakerEnabledDefault = true;
2525

2626
List<Map<String, dynamic>> _getList(dynamic object, String errorMessage) {
2727
try {
@@ -127,7 +127,7 @@ class IconTreeShaker {
127127
);
128128

129129
if (fonts.length != iconData.length) {
130-
throwToolExit(
130+
environment.logger.printStatus(
131131
'Expected to find fonts for ${iconData.keys}, but found '
132132
'${fonts.keys}. This usually means you are refering to '
133133
'font families in an IconData class but not including them '

packages/flutter_tools/test/general.shard/commands/build_aot_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void main() {
110110

111111
testUsingContext('build aot outputs timing info', () async {
112112
globals.fs
113-
.file('.dart_tool/flutter_build/0c21fd4ab3b8bde8b385ff01d08e0093/app.so')
113+
.file('.dart_tool/flutter_build/3f206b606f73e08587a94405f2e86fad/app.so')
114114
.createSync(recursive: true);
115115
when(globals.buildSystem.build(any, any))
116116
.thenAnswer((Invocation invocation) async {

packages/flutter_tools/test/general.shard/commands/build_apk_test.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ void main() {
238238
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
239239
'-Ptrack-widget-creation=true',
240240
'-Pshrink=true',
241+
'-Ptree-shake-icons=true',
241242
'assembleRelease',
242243
],
243244
workingDirectory: anyNamed('workingDirectory'),
@@ -267,6 +268,7 @@ void main() {
267268
'-Ptrack-widget-creation=true',
268269
'-Pshrink=true',
269270
'-Psplit-debug-info=${tempDir.path}',
271+
'-Ptree-shake-icons=true',
270272
'assembleRelease',
271273
],
272274
workingDirectory: anyNamed('workingDirectory'),
@@ -299,6 +301,7 @@ void main() {
299301
'-Ptrack-widget-creation=true',
300302
'-Pextra-front-end-options=foo,bar',
301303
'-Pshrink=true',
304+
'-Ptree-shake-icons=true',
302305
'assembleRelease',
303306
],
304307
workingDirectory: anyNamed('workingDirectory'),
@@ -329,6 +332,7 @@ void main() {
329332
'-Ptarget-platform=android-arm,android-arm64,android-x64',
330333
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
331334
'-Ptrack-widget-creation=true',
335+
'-Ptree-shake-icons=true',
332336
'assembleRelease',
333337
],
334338
workingDirectory: anyNamed('workingDirectory'),
@@ -353,6 +357,7 @@ void main() {
353357
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
354358
'-Ptrack-widget-creation=true',
355359
'-Pshrink=true',
360+
'-Ptree-shake-icons=true',
356361
'assembleRelease',
357362
],
358363
workingDirectory: anyNamed('workingDirectory'),
@@ -420,6 +425,7 @@ void main() {
420425
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
421426
'-Ptrack-widget-creation=true',
422427
'-Pshrink=true',
428+
'-Ptree-shake-icons=true',
423429
'assembleRelease',
424430
],
425431
workingDirectory: anyNamed('workingDirectory'),
@@ -476,6 +482,7 @@ void main() {
476482
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
477483
'-Ptrack-widget-creation=true',
478484
'-Pshrink=true',
485+
'-Ptree-shake-icons=true',
479486
'assembleRelease',
480487
],
481488
workingDirectory: anyNamed('workingDirectory'),

packages/flutter_tools/test/general.shard/commands/build_appbundle_test.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ void main() {
225225
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
226226
'-Ptrack-widget-creation=true',
227227
'-Pshrink=true',
228+
'-Ptree-shake-icons=true',
228229
'bundleRelease',
229230
],
230231
workingDirectory: anyNamed('workingDirectory'),
@@ -257,6 +258,7 @@ void main() {
257258
'-Ptarget-platform=android-arm,android-arm64,android-x64',
258259
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
259260
'-Ptrack-widget-creation=true',
261+
'-Ptree-shake-icons=true',
260262
'bundleRelease',
261263
],
262264
workingDirectory: anyNamed('workingDirectory'),
@@ -272,7 +274,6 @@ void main() {
272274
testUsingContext('guides the user when the shrinker fails', () async {
273275
final String projectPath = await createProject(tempDir,
274276
arguments: <String>['--no-pub', '--template=app']);
275-
276277
when(mockProcessManager.start(
277278
<String>[
278279
gradlew,
@@ -281,6 +282,7 @@ void main() {
281282
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
282283
'-Ptrack-widget-creation=true',
283284
'-Pshrink=true',
285+
'-Ptree-shake-icons=true',
284286
'bundleRelease',
285287
],
286288
workingDirectory: anyNamed('workingDirectory'),

0 commit comments

Comments
 (0)