Flutter dev-container #162
Comments
@bhack @DanTup RE: Dart-Code/Dart-Code#2154, yes, absolutely happy to review and integrate a PR. Anything contributed here will show up in VS Code (Open in Container..., Add Development Container Configuration Files...). |
It could be also interesting to have this as prebuilt image. See #154 |
/cc @MFAshby @AlukardBF |
Happy to clean mine up and raise a PR. The main concern I have is it requires elevated privileges to talk to USB devices, for on-device debugging. I don't have a great alternative though. |
I think there could be multiple Flutter containers (flutter-web, flutter-android, ...) - for example Android requires the Android SDK and elevated permissions to use a physical device, but using Web wouldn't require either (there are still some issues using web in containers, which is why I hadn't tidied mine up into a PR yet). It's also possible to use Android with a remote emulator (eg. Genymotion) that would not require elevated permissions, so maybe it's something that could be commented out in the config file with a note in the readme that if you want to use a physical Android device you can uncomment it (this avoids elevated permissions by default)? If you have a ADB on the host, you might also be able to use a physical device without elevated permissions, but it's not something I've tried (and having a local Android SDK somewhat underminws the idea of having everything in a container). |
Yes I think the best strategy Is probably to start with a flutter-android isolated PR and then expand over with single PRs introducing flutter-web etc.. |
Here also a version with emulator (X11 permissions): /cc @midnightblue69 |
If there Is any problem about X11 permissions for the emulator we could suggest to use https://github.com/mviereck/x11docker |
X11docker requires special tools on the host ? |
@joeblew99 Check https://github.com/mviereck/x11docker#dependencies |
Just for tracking this depend on microsoft/vscode-remote-release#2067 |
Yes, I'm trying to setup flutter in dev container too. But the matter is I cannot map host's Chrome to the container, then flutter refuses to recognize the mapped Chrome as executable, also it's difficult to map different OS's Chrome path. I believe the debugger for Chrome plugin should have the capability to attach the connection from host to container, and debugger for Chrome holds the host application path (different Chrome path for different OS) and execution. Is there any way possible for VSCode to place something like a symlink inside the docker as an executable invoked by flutter? |
Also different port used by flutter has to be exposed from docker, this is tricky... |
There's a web-server device built into Flutter to support remoting like this. You'll need to the Dart Debug extension to connect the Chrome debugger back to the VS Code extension host though. I have a sample repo here (it's designed for Codespaces, but doesn't work there currently due to how the VS Codespaces proxy works):
Then the app should load (and in theory, breakpoints and debugging should work too - though like Flutter's web support, this is still a bit work-in-progress). |
Hey @DanTup maybe you have an idea whats happening in my setup. I setup a docker image and the following files in my Dockerfile
devcontainer.json {
"name": "Flutter",
"dockerFile": "Dockerfile",
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"dart-code.dart-code",
"dart-code.flutter"
],
"remoteUser": "vscode",
"runArgs": [
"--device",
"/dev/kvm",
"--device",
"/dev/dri:/dev/dri",
"-v",
"/tmp/.X11-unix:/tmp/.X11-unix",
"-e",
"DISPLAY"
]
} On Linux I can use the android emulator without any problem but when I try to target Launching lib/main.dart on Web Server in debug mode...
Waiting for connection from Dart debug extension at http://localhost:45207
ERROR - 2020-05-25 12:14:50.692790
GET /dwds/src/injected/client.js
Error thrown by handler.
NoSuchMethodError: The method 'toFilePath' was called on null.
Receiver: null
Tried calling: toFilePath()
dart:core Object.noSuchMethod
createInjectedHandler.<fn>.<fn> (package:dwds/src/handlers/injected_handler.dart:35:39) I also have installed the chrome dart debug extension. Have you / someone else seen this error before? Maybe related to the newest beta version? EDIT: Your example repository with the latest master version is working. EDIT2: Manually running without debug |
@matsp the error you posted has been raised at flutter/flutter#54971. I don't think it should break anything though - it happens when a file is requested that should be a 404.
Great! :-) |
@DanTup Thanks for the reply! When I switch the channel of flutter to EDIT: Could be related to this flutter/flutter#57855 |
Sorry, I misread the error.. I'd seen the error before, but the 404 in my case was for a font. In your case it looks more serious:
I'll do some testing and see if I can repro here. |
@matsp I don't seem to be able to repro - I fan using the How did you change to beta? I did it by updating the
If you did it by changing at the terminal, you may need to run |
@DanTup I tested this with my own image where I am using a fixed version from SDK archive. Executing |
I do not - this does sound weird. I do know that the archive versions have their own PubCache shipped inside the archive though (in the |
I did a diff with the flutter directory before and after the https://gist.github.com/matsp/3d81b9cc6e757b5b0799f5994bacb1b9 Now it's clear why I need to update. The SDK is delivered with a URI that does not match. So integrating the command in my Docker image should fix the problem. |
@matsp thanks for checking! I downloaded the latest Dev and Beta zips, and was able to repro issues locally. I'm not sure this is supposed to be required, so I've filed a bug here: flutter/flutter#58003 |
Hi Folks, this dev-container (https://github.com/lucashilles/flutter-dev-container) works great with @DanTup extension. Working on it to improve compatibility and other functionalities. |
Any update on this? |
Gentle ping, any update now that we have Flutter 2? |
I updated this a bit |
Please add a flutter container. See Dart-Code/Dart-Code#2154
/cc @DanTup
The text was updated successfully, but these errors were encountered: