-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Working on a new widget in the widgets layer, I defined a const Icon using the ascii value for the IconData:
const Icon(IconData(0x25BA));Since the Icon widget is defined in the widgets layer, I thought this should work fine. Running an app with this builds and works fine.
When I pushed a PR, CI was very unhappy. This use of Icon results in an error from the IconTreeShaker.
flutter build apk --release
Target aot_android_asset_bundle failed: IconTreeShakerException: Invalid ConstFinder result. Expected "fontPackage" to be a String, "fontFamily" to be a String, and "codePoint" to be an int, got: {codePoint: 9658, fontFamily: null, fontPackage: null, matchTextDirection: false, fontFamilyFallback: null}.
To disable icon tree shaking, pass --no-tree-shake-icons to the requested flutter build command
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command '/Users/katelovett/_github/flutter/bin/flutter'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 14s
Running Gradle task 'assembleRelease'... 14.7s
Gradle task assembleRelease failed with exit code 1
I figured I was holding it wrong and was not allowed to do this, but @goderbauer suspects this is a bug in the icon tree shaker script.
This can be reproduced with the following code and the command flutter build apk --release
import 'package:flutter/material.dart';
void main() => runApp(const SliverTreeExampleApp());
class SliverTreeExampleApp extends StatelessWidget {
const SliverTreeExampleApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: SliverTreeExample(),
);
}
}
class SliverTreeExample extends StatelessWidget {
const SliverTreeExample({super.key});
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(child: Icon(IconData(0x25BA)),),
);
}
}
This is an example build where I saw this in CI: https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20build_tests_2_3/33418/overview