DEV Community

Vim as a Flutter IDE

Morteza Tavanarad on January 16, 2020

If you are such developers who love vim and use it instead of other IDEs and you are a Flutter developer, you are in the right place. In the contin...
Collapse
 
edieatha profile image
Edie Atha

Hello, Thanks for the Great tutorial:
However am getting this error when I open a "main.dart" file in vim

"Developer/flutter_app/lib/main.dart" 111L, 4371C
Error detected while processing function lsc#dart#register[1]..117_FindCommand[1]..117_FindDart:
line 8:
Could not find a dart executable

Any Help?

Collapse
 
junery115_25 profile image
Japheth Awah

Well what you have to do is install dart on your system, or make sure that the path to the executable is added to your environment variables.

Collapse
 
junery115_25 profile image
Japheth Awah

Yeah I see everyone doing this, i set it up and it works flawlessly but how do I connect my application to the emulator, like with visual studio code when I just run flutter run it runs on the emulator.

Collapse
 
igaurab_55 profile image
igaurab • Edited

There are different commands that you can run which are mentioned in the coc-flutter repo:
github.com/iamcco/coc-flutter

For your particular problem there are two commands you should run:
:CocCommand flutter.emulators
This list the installed emulators on your devices, just select the one and press Enter

Inorder to run the current application
:CocCommand flutter.run

This is similar to flutter run

Now you can bind these two commands into a keybinding and use that keybinding instead

nnoremap leader e :CocCommand flutter.emulators CR
nnoremap leader r :CocCommand flutter.run CR

** I am not able to put the leader as a tag. Dev doesn't allow that.

Collapse
 
igaurab_55 profile image
igaurab

I really loved the refactor code of the vs code, how do I make it work with coc-flutter, as of now, I only see the option to extract my widget. I wanted to wrap with current widget with another widget. Is there a way around? Am I missing something?

Collapse
 
haruanm profile image
Haruan Justino

I'm also searching for a way to do that in nvim

Collapse
 
marciofrayze profile image
Marcio Frayze

I'm looking for a way to auto-import missing imports. I'm able to do that with Java, but no luck with dart/flutter yet. Any tips?

Collapse
 
marciofrayze profile image
Marcio Frayze

Just found a way to do that, just typing: ga

Thanks for this post. Vim <3

Collapse
 
tavanarad profile image
Morteza Tavanarad

Also, you can use :CocAction for more actions like sorting imports, removing unused imports and so on.

Collapse
 
bakercode profile image
Beicker

Does someone knows how to avoid this warning?

[dart_omit_local_variable_types] [I] Omit annotations for local variables.

I just want to work indicating the data type of the variables, not only with 'var' keyboard

Collapse
 
bakercode profile image
Beicker

Sorry sorry hahaa I found what I wanted. Just needed to add the next lines to the analysis_options.yaml

linter:
rules:
- camel_case_types
- omit_local_variables_types: false

And it works perfectly.

Collapse
 
mathslover profile image
Suraj Pal Singh

I must say that coc.nvim is by far best intellisense engine for vim/neovim.
I use it for go, c++, flutter/dart, bash, latex and never got disappointed.

Collapse
 
tavanarad profile image
Morteza Tavanarad

I couldn't agree more.

Collapse
 
mhadaily profile image
Majid Hajian

Great article, good job Morteza

Collapse
 
tavanarad profile image
Morteza Tavanarad

Thanks Majid 🙏

Collapse
 
vladoenter profile image
Vladimir Tamayo

Thaks works perfect

Collapse
 
romulocollopy profile image
Rômulo Collopy

A tip for asdf(asdf-vm.com/) users:

reslving to the shim my not work. Try

let g:lsc_dart_sdk_path='~/.asdf/installs/flutter/2.5.3-stable/

Collapse
 
mitai profile image
Mitai
Collapse
 
me52676285 profile image
Me

What about debugging? How do you debug flutter app in vim?

Collapse
 
peekpt profile image
Paulo Bruckmann

silence

Collapse
 
navidshad profile image
Navid

I got it to work after 2 days :D, thanks for this amazing instruction (y)