akinsho / flutter-tools.nvim

Tools to help create flutter apps in neovim using the native lsp
MIT License
932 stars 75 forks source link

[Help] How to debug example project of a library #329

Open tlvenn opened 4 months ago

tlvenn commented 4 months ago

Is there an existing issue for this?

Current Behavior

When I start a flutter run command on a library, the process stops saying there is no /lib/main.dart

Expected Behavior

Ideally, it would be great if it could detect the example folder and start example/lib/main.dart.

Steps To Reproduce

In any library project having an example sub project

Environment

Not relevant

Anything else?

I tried to play with .nvim.lua to see if I could leverage this but it did not work. Thanks in advance for any tip on how to do this.

Thesmader commented 4 months ago

Hi @tlvenn, you could open up the example directory in neovim and try the FlutterRun command. Can you share your .nvim.lua configuration here? The following minimal configuration with .nvim.lua seems to be working correctly:

require 'flutter-tools'.setup_project({
  {
    name = "Development",
    target = "example/lib/main.dart"
  }
})
bruce3x commented 3 months ago

My .nvim.lua :

require("flutter-tools").setup_project({
    {
        name = "Development",
        target = "example/lib/main.dart",
    },
})

When I try the FlutterRun, failed

Launching example/lib/main.dart on ONEPLUS A6013 in debug mode...
AndroidManifest.xml could not be found.
<library-root>/android/AndroidManifest.xml for errors.
No application found for TargetPlatform.android_arm64.
Is your project missing an android/AndroidManifest.xml?
Consider running "flutter create ." to create one.

It can't recognize the android project in the example/android directory.

tlvenn commented 2 months ago

Sorry @Thesmader, somehow missed your reply... I tried with various .nvim.lua including yours without success, every time the command fails with /lib/main.dart does not exist error. I am surprised you got this working somehow on your side.

Any chance you can provide a dummy hello world lib repo featuring this so I can checking out on my side ? Thanks in advance.

tlvenn commented 2 months ago

@sidlatau wondering if this works for you or if you have a way to achieve this.

tlvenn commented 2 months ago

Tried again today to dig into this and something I tried in the past which was not working is actually working just fine now....I essentially go the example dir, open nvim and start the example. This time however, nvim can navigate to the parent lib and breakpoints work as well.

Ideally I wish the suggestion @Thesmader made would work as it would be more logical / intuitive but right now it does not, i tried again with a dummy project. I can commit it to see if you can reproduce it on your end if you have the time @Thesmader, let me know.