Error: Type 'FontFeature' not found. Flutter google_fonts package error

9.1k views Asked by At

When using the latest version of google_fonts (6.2.0) package in flutter project, I'm facing this 'Type FontFeature not found' issue:

/C:/Users/Dell/AppData/Local/Pub/Cache/hosted/pub.dev/google_fonts-6.2.0/lib/src/google_fonts_base.dart:69:8: 
Error: 'FontFeature' isn't a type.
  List<FontFeature>? fontFeatures,
       ^^^^^^^^^^^
Target kernel_snapshot failed: Exception


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1

I tried downgrading the package version but the issue persists. Also tried flutter clean and pub get..

8

There are 8 answers

1
Afrad Ahsan On BEST ANSWER

To everyone facing this issue, downgrade to an older version 6.1.0 (recommended) to get this issue solved. Also, keep this in mind:

When you downgrade packages, make sure to remove the caret (^) in front of the version number. For example: google_fonts: 6.1.0

Thanks to @Dhafin Rayhan for pointing it out.

0
neegashi On

use this google_fonts: ^5.1.0 this worked for me.

1
FAROOQ AHMAD On

If you are using google fonts package version above 6.1.0 in pubspec.yaml file then downgrade it to 6.10 or more lower then this issue will be resolved.

Note : remove the ^ this as well.

Example google_fonts: ^6.2.0 => google_fonts: 6.1.0

0
OverdoseB12 On

This is a problem with the google_fonts package.

Change the package version in pubspec.yaml from ^6.2.0 to 6.1.0

This worked for me!

2
huandrey On

por garantia roda um flutter clean, apaga o pubspec.lock e rodem novamente o flutter pub get. e não pode esquecer de tirar o "ˆ" antes de rodar o flutter pub get.

0
Fahad Jalil On

This is a problem with the google_fonts package. If you are using google fonts package version above 6.1.0 in pubspec.yaml file then downgrade it to 6.10 or more lower then this issue will be resolved.

Change the package version in pubspec.yaml from ^6.2.0 to 6.1.0

Note: Also remove caret (^) icon as well from the front of version number.

This worked for me!

0
Apurva Gaurav On

I tried other solutions including the ones to downgrade but they either created new problems or the particular font I was trying to use was not available.

I just had to upgrade flutter using the "flutter upgrade" command in the terminal and that worked in my case. Would recommend doing this before resorting to alternative troubleshooting methods.

0
Taher Salah On

you can try use this google_fonts: ^5.1.0 this worked for me.