1

We use Flutter with VSCode. We have been able to debug as expected with the following commands.

fvm flutter run --debug --flavor production --target lib/main-production.dart

But when we press F5 to run from VSCode, the following code throws a MissingPluginException.

~/fvm/versions/2.10.5/packages/flutter/lib/src/services/platform_channel.dart

  @optionalTypeArgs
  Future<T?> _invokeMethod<T>(String method, { required bool missingOk, dynamic arguments }) async {
    assert(method != null);
    final ByteData? result = await binaryMessenger.send(
      name,
      codec.encodeMethodCall(MethodCall(method, arguments)),
    );
    if (result == null) {
      if (missingOk) {
        return null;
      }
      throw MissingPluginException('No implementation found for method $method on channel $name');
    }
    return codec.decodeEnvelope(result) as T?;
  }

We want to debug pressing F5 as well as the command case. We have set up launch.json as follows Isn't this the same command we are running?

.vscode/launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Production(Debug)",
      "request": "launch",
      "type": "dart",
      "program": "lib/main-production.dart",
      "args": [
        "--debug",
        "--flavor",
        "production",
      ]
    },
  ]
}

We are using fvm, but it looks like Flutter 2.10.5 is being used both in VSCode and in the command.

.fvm/fvm_config.json

{
  "flutterSdkVersion": "2.10.5",
  "flavors": {}
}
fvm --version
2.4.1
fvm flutter --version
Flutter 2.10.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5464c5bac7 (5 months ago) • 2022-04-18 09:55:37 -0700
Engine • revision 57d3bac3dd
Tools • Dart 2.16.2 • DevTools 2.9.2

[Added] We also set the global Flutter version to 2.10.5 but the error remained the same.

% fvm use 2.10.5      
Project now uses Flutter [2.10.5]

% fvm global 2.10.5
Flutter "2.10.5" has been set as global

% fvm doctor

FVM Version: 2.4.1
___________________________________________________

FVM config found:
___________________________________________________

Project: daigas_capture
Directory: /Users/xxxxx/zzzzz
Version: 2.10.5
Project Flavor: None selected
___________________________________________________

Version is currently cached locally.

Cache Path: /Users/xxxxx/fvm/versions/2.10.5
Channel: false
SDK Version: 2.10.5

IDE Links
VSCode: .fvm/flutter_sdk
Android Studio: /Users/xxxxx/zzzzz/.fvm/flutter_sdk


Configured env paths:
___________________________________________________

Flutter:
/Users/xxxxx/fvm/default/bin/flutter

Dart:
/usr/local/bin/dart

FVM_HOME:
not set
Ganessa
  • 782
  • 2
  • 7
  • 24
  • try changing the default(global) flutter version in fvm to 2.10.5. if this fixes the issue then the launch.json uses the default flutter version instead of the one specified in fvm config – Arin Faraj Sep 28 '22 at 09:13
  • Thanks for your comments. We set our global Flutter version to 2.10.5, but still the error remained the same. – Ganessa Sep 29 '22 at 00:29
  • @Ganessa did you manage to solve this? I am facing the same thing. – A.Ktns Apr 03 '23 at 17:23
  • @A.Ktns Thanks for the comment. Unfortunately I've been off Flutter related projects for some time now and have forgotten about them. I will share when I remember. – Ganessa Apr 06 '23 at 01:25

1 Answers1

1

Make sure to follow the fvm configuration for VSCode Which states that you need these settings inside .vscode/settings.json

{
  "dart.flutterSdkPath": ".fvm/flutter_sdk",
  // Remove .fvm files from search
  "search.exclude": {
    "**/.fvm": true
  },
  // Remove from file watching
  "files.watcherExclude": {
    "**/.fvm": true
  }
}
Arin Faraj
  • 358
  • 2
  • 14
  • Thanks for your comments. We mistakenly thought this solved the problem, but an identical error still occurs today. – Ganessa Sep 29 '22 at 00:31
  • try this in the `launch.json` file { "name": "Production(Debug)", "request": "launch", "flutterMode": "debug", "type": "dart", "program": "lib/main-production.dart", "args": [ "--flavor", "production", "--target", "lib/main-production.dart" ] }, – Arin Faraj Sep 29 '22 at 11:10
  • Thank you for your comment! But MissingPluginException still occurs. – Ganessa Sep 29 '22 at 13:56