akinsho / flutter-tools.nvim

Tools to help create flutter apps in neovim using the native lsp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Help] How to debug example project of a library

tlvenn opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

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.

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"
  }
})

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.

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.

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

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.