2

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

ajnabz
  • 297
  • 5
  • 25
  • happy to give this a try on my system if you have created any open source sample project to reproduce the same? – jignesh.world Mar 06 '21 at 12:44
  • I can't able to access this repo.. can you please make this public if it's private currently? – jignesh.world Mar 07 '21 at 05:13
  • @jignesh its public now :) – ajnabz Mar 07 '21 at 11:53
  • Sorry to say but this project is incomplete and don't have enough code to make this project running,.. – jignesh.world Mar 07 '21 at 18:48
  • @jignesh what else do you need? – ajnabz Mar 07 '21 at 22:39
  • Just try to clone the repo at some other folder in the system and run the project - you will see there are multiple things missing and you can't able to run the project without additional configuration. Currently no android folder, no firebase config etc.. I would say, create a sample project to reproduce the issue and share the complete project without removing any necessary things. – jignesh.world Mar 08 '21 at 06:23
  • You can make a variable constant by writing it like this `icon: const Icon(Icons.home),` and `iconData: const IconData(document.data()['ref'], fontFamily: 'MaterialIcons')` – Naveen Rao Mar 08 '21 at 08:47
  • @jignesh I didnt want to clone the whole repo as there are some files that have private information in so I just pushed the files I had changed but I will update it now with more of the files – ajnabz Mar 08 '21 at 12:15
  • @NaveenRao unfortunately i cant use ```iconData: const IconData(document.data()['ref'], fontFamily: 'MaterialIcons')``` as the ```document.data()['ref']``` means that the value is not constant - do you know a way around this? – ajnabz Mar 08 '21 at 12:15
  • I tried cloning your code and to check what's the issue I've to setup firebase in the app. Even after setting up firebase I've to add icons in the data base exactly where you have icons in the database. Can you send me code which just have this issue but without firebase added into it. – Naveen Rao Mar 08 '21 at 12:53
  • @NaveenRao ive just reduced the amount of code so that its just one element which is giving me one error. I can't remove the firebase issue however as that is what is giving me the error. – ajnabz Mar 08 '21 at 13:27
  • Can you give me what is there in the data at `document.data()['ref']` ? – Naveen Rao Mar 08 '21 at 14:54
  • @NaveenRao Hi i have added an image to the question! Thank you! – ajnabz Mar 08 '21 at 15:04
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/229656/discussion-between-ajnabz-and-naveen-rao). – ajnabz Mar 08 '21 at 15:35
  • Yeah I've asked something in chat. I guess you didn't got notified. – Naveen Rao Mar 08 '21 at 15:59

1 Answers1

2

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'))
Naveen Rao
  • 712
  • 6
  • 10