- Create example plugin project
flutter create --org com.example --platforms=linux myapp
- From
myapp/example
runflutter run
and quit the app - Install vscode
- Install flutter plugin
- Install MS C++ plugin https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools
- Switch to Insider channel for new features
- When opening project VS code should ask you if you want to configure CMake project - answerr YES and click Locate cmake file
now this is important choose -
myapp/example/linux/CMakeLists.txt
NOT the one frommyapp/linux
- You will probably have to relaunch vscode
- inside
myapp/
folder create.vscode
(notice the dot) folder - create
c_cpp_properties.json
:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++14",
"intelliSenseMode": "linux-clang-x64",
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
- Create
settings.json
{
"cmake.sourceDirectory": "${workspaceFolder}/example/linux",
"cmake.configureOnOpen": true,
"files.associations": {
"cstring": "cpp"
}
}
- Finally create
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Flutter",
"cwd": "example",
"request": "launch",
"type": "dart",
"args": [
"--local-engine",
"/home/charafau/Utils/engine/src/out/host_debug_unopt"
]
},
{
"name": "Debug native",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/example/build/linux/x64/debug/bundle/myapp_example",
"cwd": "${workspaceFolder}"
}
]
}
take a look at this line:
"program": "${workspaceFolder}/example/build/linux/x64/debug/bundle/myapp_example",
This points to binary and will change to the name of your project, so check this folder and correct your path
also you will have remove those lines or correct paths:
"args": [
"--local-engine",
"/home/charafau/Utils/engine/src/out/host_debug_unopt"
]
I run custom build engine to you might not need that
You will have now two configurations in vscode - one for running example project and one for debugging native binary (it also launches the project)
!!! Notice that everytime you change something in your project you need to run flutter run
in order to recompile