Search code examples
flutterdartflutter-packagesgoogle-fonts

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


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..


Solution

  • 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.