Flutter VSCode extension demo!
This project demonstrates how to utilized Flutter as a Webview UI in a VSCode extension.
Steps to get started:
- You must have Flutter and Node installed (whatever lts is fine)
- Run
flutter pub getandnpm installto get all packages - With VSCode open, hit
f5to start a debug session and this will automatically compile and run everything for you. - You'll see a new VSCode instance open, you can open a debugger to see the console for the flutter webview by opening the Command Pallette for VSCode and selecting
Developer: Open Webview Developer Tools
- The Flutter
index.htmlandflutter_bootstrap.jsare custom, this is in order to accommodate strict csp rules. - Both the JS side and the Dart side play key roles in communicating with the various parts of the JS runtime. While you can use
js_interopto bridge that communication, there are ultimately different runtimes that need accommodating. Theextension.tsfile handles the VSCode runtime (which is JS) and the JS runtime that the Flutter engine sits atop is entirely separate. This is bridged through passing messages usingjs_interopandweb. - There is a build script:
scripts/compile.shthat handles both the JS and Flutter builds, it is called automatically by VSCode'slaunch.jsonthat is declared inpackage.json.