flutterfvm

Can't get project to build using fvm flutter


I'm trying to use fvm for my flutter version.

I'm running into many errors. Currently, I have this one:

../../fvm/versions/3.13.4/packages/flutter/lib/src/services/binding.dart:329:80: Error: Member not found: 'hidden'.

I have noticed that is a new value added to AppLifecycleState enum called hidden. It is in my code when I navigate to it by cmd + clicking the error.....

It seems like it is fixed when I change:

environment:
  sdk: ">=3.0.0 <3.2.0"

to

environment:
  sdk: '>=3.1.2 <4.0.0'

But then I get:

Error (Xcode): [+1157 ms] .dart_tool/flutter_build/dart_plugin_registrant.dart:1:1: Error: The specified language version is too high. The highest supported language version is 3.0.

I did flutter clean so it will regenerate .dart_tool folder but it didn't fix it.

I think it is using my global dart, not my fvm dart because fvm flutter doctor shows:

Doctor summary (to see all details, run flutter doctor -v): [!] Flutter (Channel stable, 3.13.4, on macOS 13.5.2 22G91 darwin-arm64, locale en-GB) ! Warning: flutter on your path resolves to /Users/ben/development/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/ben/fvm/versions/3.13.4. Consider adding /Users/ben/fvm/versions/3.13.4/bin to the front of your path. ! Warning: dart on your path resolves to /Users/ben/development/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/ben/fvm/versions/3.13.4. Consider adding /Users/ben/fvm/versions/3.13.4/bin to the front of your path. [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [✓] Xcode - develop for iOS and macOS (Xcode 15.0) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.3) [✓] IntelliJ IDEA Community Edition (version 2023.2.2) [✓] VS Code (version 1.83.0) [✓] Connected device (6 available) [✓] Network resources

! Doctor found issues in 1 category.


Solution

  • I use fvm and I often switch between projects for work and personal. This is the first time I've encountered this same exact error.

    /fvm/versions/3.13.0/packages/flutter/lib/src/services/binding.dart:329:80: Error: Member not found: 'hidden'.
    

    I solved it by running

    fvm flutter pub upgrade --major-versions
    

    I'm not sure why this solved it but I assume it's due to something with the global pub-cache. Hope this helps!