23

I am working on an app, I posted last update on git 2 days ago and haven't touched the code since. Now, I opened android studio and it was giving me this error when I tried to run it... I tried deleting repository from my computer and then cloning it again but it didn't work. I have also tried searching for similar problems, and found out there was a similar problem with speed-dial package and one comment said something about broken package versions. Anyways, this is the error I am getting after I try running my app:

enter image description here

These are first few lines of the error it's giving me, but there is more than a thousand lines following these.

I also tried running flutter doctor and it gave me the following:

enter image description here

7 Answers7

35

google_fonts: ^2.3.1 has also solved the problems left in google_fonts: 2.3.0

Well! This issue will be raised in all projects using the google_fonts with a caret sign (^).

The caret sign (^) is used for pub dependencies in Dart to indicate a range of version numbers that are allowed. Specifically, any version from the specified version up to (but not including) the next non-breaking version is ok.

So google_fonts: ^2.2.0 is the same as '>=2.2.0 <3.0.0', It's shorthand for the longer form. The ^ is saying, I want to automatically use the most up-to-date package from Pub as long as that update won't break anything in my app. The google_fonts: 2.3.0 has some issues with this as of now.

Solution Steps :

  1. Remove (^) from your current google_fonts. max can be set as google_fonts: 2.2.0.
  2. To make sure, this does not conflict with any other dependency, for once do 'pub get'.
  3. Try to invalidate caches and restart. This should clean error, else do flutter clean to remove old updated google_fonts and pub get.

Done! You are good to go. Happy Codding!!!

ViKi Vyas
  • 691
  • 5
  • 16
18

Well, I don't know if you have tried this, but this problem is described here: issue 219

In summary, you have to use google_fonts v2.3 for Flutter v2.1 or greater.

Pang
  • 9,564
  • 146
  • 81
  • 122
Firus
  • 537
  • 1
  • 5
  • 18
  • 3
    Thanks for finding this solution, what a super-annoying bug; it appeared all of the sudden when running widget tests, such as `flutter test test/widget_test.dart`. This bug probably means a large number of flutter tests will fail after `flutter pub upgrade`. I confirm the linked suggestion fix the issue - in particular, I changed dependencies in pubspec.yaml from `google_fonts: ^2.2.0` to `google_fonts: 2.2.0`. – mzimmermann Feb 05 '22 at 18:57
  • 1
    Great. If your problem has been resolved, please consider mark this questions as aswered. – Firus Feb 08 '22 at 16:38
  • I upvoted your solution but I do not think I can accept, as I am not the original question author. – mzimmermann Feb 09 '22 at 17:29
18

Please follow the below steps to solve the issue.

  1. Open pubspec.yaml file.
  2. Change google_fonts: ^2.2.0 to google_fonts: 2.2.0
  3. Save.
ruwanmadhusanka
  • 851
  • 2
  • 8
  • 15
10

set the package version to google_fonts: 2.2.0 and it should work properly

Mr.A2
  • 126
  • 4
0

as they said, just remove the ^ from the google fonts on the dependencies on the pubspec.yaml (google_fonts: ^2.3.1 to google_fonts: 2.3.1) then flutter clean && pub get.

Yahia
  • 31
  • 4
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 17 '22 at 05:49
0

In my case it was happening with the windows directory only i fixed it just deleting my pubspec.lock, podfile.lock file and reinstalling packages , which fixed this for me

Uzair Leo
  • 121
  • 1
  • 3
-1

I had the same problem but it was not an issue with dependencies as for others. I stopped getting this error when I put "shape" in the scope of styles.

Example with my problem:

      ElevatedButton(
        child: Text('Sign in with Google'),
        onPressed: _signInWithGoogle,
        style: ElevatedButton.styleFrom(
          backgroundColor: Colors.white,
          foregroundColor: Colors.black,
        ),
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(16.0),
        ),
      ),

Example when "shape" stopped giving an error:

      ElevatedButton(
        child: Text('Sign in with Google'),
        onPressed: _signInWithGoogle,
        style: ElevatedButton.styleFrom(
          backgroundColor: Colors.white,
          foregroundColor: Colors.black,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(16.0),
          ),
        ),
      ),
Montekar
  • 104
  • 4