Closed TankOs closed 1 month ago
The detection of Flutter yes/no is a regex: https://github.com/nvim-flutter/flutter-tools.nvim/blob/ea1d398f543a54ba95357c3b8bb9d6f68eaec36c/lua/flutter-tools/commands.lua#L206
I asked AI to allow quotes and it came up with:
local is_flutter_pattern = "flutter%s*:%s*sdk%s*:%s*['\"]?flutter['\"]?"
local flutter_dependency = string.match(joined_content, is_flutter_pattern)
This fixes the quotes I suppose - an actual yaml parser implementation would be argueably more robust.
AI should have told you that any regexp is not reliable 😉, because you have no idea how YAML is going to progress in the future, and you won't be able to handle all existing solutions, even now. One might use YAML anchors or other fancy things already.
Is there an existing issue for this?
Current Behavior
When the
sdk: flutter
line in my pubspec.yaml isn't formatted as expected by flutter-tools, it won't recognize my project as being a Flutter project, but instead launches with a Dart project configuration.Expected Behavior
The detection of Flutter projects should work independently from how the pubspec.yaml is formatted. For example, if I use double quotes (
sdk: "flutter"
), then the project should still be detected as a Flutter project.Steps To Reproduce
flutter
to"flutter"
.:FlutterRun
. It will say "Starting Dart project..." instead of "Starting Flutter project...".Environment
Anything else?
I think the detection code is not reliable (single quotes are also valid in YAML, and maybe tons of other ways). It's also possible to insert the expected string somewhere in the file, where it doesn't have any purpose, and still trigger the Flutter build.