androidflutterdart

This application cannot tree shake icons fonts. Flutter build error for android deployment


I'm building my flutter and firebase application for android and am currently getting the error This application cannot tree shake icons fonts. I have been looking at some other questions like this one. However, one of the suggestions, using --no-tree-shake-icons, doesn't work as when the app is built, none of the icons I have used show up. The other suggestion is to add const before IconDate but I cant figure out how to do this as most of my icons are declared as:

icon: Icon(Icons.home),

or

iconData: IconData(document.data()['ref'], fontFamily: 'MaterialIcons')

If anyone would be able to assist in showing me how to add const or how this issue can be resolved, I would really appreciate it!

EDIT: This is an example of what is in my cloud firestore: enter image description here


Solution

  • Going through your given code it seems like Positioned widget is causing icons to disappear in profile and release mode.

    Please change this :

    Positioned(
    child: new DailyButton(
    colourData: Color(0xFFFD15BE),
    outlineData: Color(0xFFFD15BE),
    onTap: () {},
    iconData: new IconData(58808, fontFamily: 'MaterialIcons')))
    

    to this :

    DailyButton(
    colourData: Color(0xFFFD15BE),
    outlineData: Color(0xFFFD15BE),
    onTap: () {},
    iconData: new IconData(58808, fontFamily: 'MaterialIcons'))