fluttercommunity / font_awesome_flutter

The Font Awesome Icon pack available as Flutter Icons
Other
834 stars 236 forks source link

'IconData' isn't a type. #168

Closed axilos closed 3 years ago

axilos commented 3 years ago

In font_awesome_flutter.dart all IconData are marked with error: 'IconData' isn't a type.

For example, this line: static const IconData zero = const IconDataRegular(0x30);


Other notices:

import 'package:flutter/widgets.dart'; is greyed out.

Also in example/lib/main.dart: icon: FaIcon(FontAwesomeIcons.search), 'search' is underlined red (The getter 'search' isn't defined for the type 'FontAwesomeIcons'.)

example/lib/icons.dart is also underlined red but inside the file there is nothing marked. 'Analysis completed 6 errors found 716 typos found' Screenshot_1

michaelspiss commented 3 years ago

Hi! Based on your screenshot, it looks like you didn't run flutter pub get yet. Run it in your project root. import 'package:flutter/widgets.dart'; is where the IconData class lives. It should be green once you've done the step above. search is not underlined red for me, please check again after running flutter pub get. If it's still there, please open another issue with the output of flutter doctor -v.

axilos commented 3 years ago

Hi and thank you on your fast respond.

I'm still stuck...

I have pro icons and I have followed the guide:

`Download this package's newest release, extract the folder, move it to a location of your choice and go to that directory Remove #s from pubspec.yaml at the indicated position run flutter packages get Download your font awesome pro icons (web version) Move all .ttf files from the webfonts directory to /path/to/your/font_awesome_flutter/lib/fonts (replace existing fonts) Note: Please make sure all .ttf files (and the following icons.json) are of the same version to avoid missing icons! Move icons.json from metadata to /path/to/your/font_awesome_flutter From there run ./tool/update.sh on linux or .\tool\update.bat on windows Note for windows users: Please run the script in cmd or powershell only. Flutter is known to have problems with third-party shells. Add version >= 4.7.0 to your project's dependencies, Override it with the path to your local installation: dependencies: font_awesome_flutter: '>= 4.7.0' ...

dependency_overrides: font_awesome_flutter: path: /path/to/your/font_awesome_flutter ...`

I did it step by step strictly. Only I had to move update.bat from /tool directory to /font_awesome_flutter directory. font_awesome_flutter directory is in the project root. I copied it from the git as newest release. I did pub get on main pubspec.yaml and on pubspec.yaml in /font_awesome_flutter directory. Copied fonts with overwritting 3 of them.

Update is done without any errors ("Custom icons.json found, using local data only.").

And I have still same error in font_awesome_flutter.dart file inside /font_awesome_flutter/lib.

Icons.dart now has 13866 errors: Screenshot_2

It says ExampleIcon is not defined.

axilos commented 3 years ago

I found the cause of the problem.

In icons.json there is a field "360-degrees" and it is generated into: static const IconData 360Degrees = const IconDataRegular(0xe2dc);

Variable name can't start with number...

This causes whole big file font_awesome_flutter to popup errors "IconData isn't a type".

I have renamed "360-degrees" into "degrees-360" and start update again.

P.S. FontAwesomeIcons.search icon not exist and it is used in example/lib/main.dart, row 103.