Difference between flutter run and flutter run -d - flutter

AFAIK, when you run the following command, it runs the app in the debug mode.
flutter run
But the following command also does the same thing. So, is there any difference between the two commands?
flutter run -d

-d lets you specify a run target, e.g. flutter run -d web or flutter run -d linux
$ flutter run linux
Target file "linux" not found.
$ flutter run -d linux
Launching lib/main.dart on Linux in debug mode...
Building Linux application...
$ flutter run --help
Run your Flutter app on an attached device.
Global options:
-d, --device-id Target device id or name (prefixes allowed).
Command (linux part without -d) is a --target flag by default:
-t, --target=<path> The main entry-point file of the application, as run on the device.
If the --target option is omitted, but a file name is provided on the command line, then that is used instead.
(defaults to "lib/main.dart")

Related

Flutter web | failed to create Docker file

Below issue facing while creating docker file in flutter web
enter image description here
anyone have idea about how to create docker file in flutter web.....
I tried many resources but still stuck in issue...
resource or link or solution about same
It is hard to help you without seeing your Dockerfile.
This is the multistaged one I use with nginx:
#Stage 1 - Install dependencies and build the app
FROM debian:latest AS build-env
# Install flutter dependencies
RUN apt-get update
RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback lib32stdc++6 python3
RUN apt-get clean
# Clone the flutter repo
RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter
# Set flutter path
# RUN /usr/local/flutter/bin/flutter doctor -v
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"
# Run flutter doctor
RUN flutter doctor -v
# Enable flutter web
RUN flutter channel master
RUN flutter upgrade
RUN flutter config --enable-web
# Copy files to container and build
RUN mkdir /app/
COPY . /app/
WORKDIR /app/
RUN flutter create .
RUN flutter build web
# Stage 2 - Create the run-time image
FROM nginx:1.21.1-alpine
COPY --from=build-env /app/build/web /usr/share/nginx/html
If you need a highly optimized image I would not use this one. How ever it does the trick for me.

How debug a Flutter test running inside a Docker container

I am following the Reduce your CI cost using Docker to run local tests article and managed to run my tests inside a Ubuntu docker container. However, I have one test which fails after about 10 minutes of running. Here is the error I see:
# flutter test test/lib/mobile/services/sync/sync_service_test.dart
12:25 +0 -1: apiSync It should throw an exception if the sync fails [E]
TimeoutException after 0:10:00.000000: Test timed out after 10 minutes.
dart:isolate _RawReceivePortImpl._handleMessage
However, this test runs fine in macOS (my machine and in Bitrise CI).
To help resolve this issue, I am trying to find a way to debug this test. Is there a way I can remotely debug a test running inside this Docker container?
This is a copy of my modified Dockerfile:
# Need to match the version of Linux your CI is running on
FROM ubuntu:20.04
# Prerequisites
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Paris
RUN apt update && apt install -y curl git unzip xz-utils zip libglu1-mesa openjdk-8-jdk wget libsqlite3-dev
WORKDIR /home/developer
# Download Flutter SDK
ARG flutter_version
RUN git clone https://github.com/flutter/flutter.git -b ${flutter_version}
ENV PATH "$PATH:/home/developer/flutter/bin"
COPY pubspec.* /home/developer/project/
WORKDIR /home/developer/project
RUN flutter pub get
COPY *.yaml *.json /home/developer/project/
COPY android /home/developer/project/android
COPY assets /home/developer/project/assets
COPY doc /home/developer/project/doc
COPY docker /home/developer/project/docker
COPY ios /home/developer/project/ios
COPY lib /home/developer/project/lib
COPY macos /home/developer/project/macos
COPY scripts /home/developer/project/scripts
COPY test /home/developer/project/test
COPY test_environment /home/developer/project/test_environment
COPY tool /home/developer/project/tool
COPY web /home/developer/project/web
# Run basic check to download Dark SDK
RUN flutter doctor
I would like to know the possibility of remote debugging rather than trying to solve the issue for this particular test.
Thanks in advance 🙏 !!!

is it possible to get the futter path dynamic in terminal when using fvm

I am written a shell script to upgrade the flutter dependencies in terminal. this is the shell script looks like:
#!/usr/bin/env bash
set -u
set -e
set -x
# https://flutter.cn/community/china
export PUB_HOSTED_URL=https://mirrors.tuna.tsinghua.edu.cn/dart-pub
export FLUTTER_STORAGE_BASE_URL=https://mirrors.tuna.tsinghua.edu.cn/flutter
~/apps/flutter/bin/flutter pub upgrade
now I changed to using fvm to manage the flutter version, the version always swithed by time. is it possible to get the current flutter version dynamic in terminal so that I did not need to change the shell script even the flutter upgrade or changed the execute path. I have tried this way to print the current path seems did not work:
➜ retire git:(master) ✗ fvm list
Cache Directory: /Users/xiaoqiangjiang/fvm/versions
2.10.5
2.10.3
2.8.0
2.5.1
➜ retire git:(master) ✗ whereis flutter
flutter:
step 1: flutter --version
step 2: flutter doctor -v
after performing 2nd step you will get to know your flutter sdk path which clearly mention in 2nd line of your output.
if you want to update flutter, proceed with this command:
flutter upgrade

codemagic keep build with error: '.../Pods-Runner/Pods-Runner-frameworks-Release-input-files.xcfilelist' `

PS: I can use Xcode to build the version successfully.
I got the similar error when use codemagic. unable-to-load-contents-of-file-.
After made the changed mentioned in the above link.
I got build error in codemagic, but didn't should any message releated to build error.
you can try to update your pods to match the new version or downgrade pods with the following custom script:
#!/bin/sh
set -e # exit on first failed command
set -x # print all executed commands to the terminal
yes | gem uninstall cocoapods -v 1.7.2 || true
gem install cocoapods -v 1.6.1
One tip to show more logs is to enter -v or --verbose to build arguments in the build section.

Perfect Asistant: Build Linux failed due to module cache path on linux vs macOS

I tried to follow along the Perfect screencast from RayWenderlich on a Mac. On Perfect Asistant (2nd screencast), he showed using Perfect Assistant, we could just click on the Build Linux and it will build on Linux given we have installed the Docker.
In my case it started to compile then it failed with error that current module cache path and the module cache path the PCH was compiled was not the same. I don't know how to update the module cache path just for Linux.
Here are the console output:
Starting Linux build of /Users/hange/Developer/RayWenderlich/Practices/ServerSide_Perfect/hello-perfect-assistant
Using image perfectassistant/helloperfectassistant
Using image perfectassistant/helloperfectassistant
Compile COpenSSL openssl.c
Compile LinuxBridge LinuxBridge.c
error: PCH was compiled with module cache path '/perfectbuild/.build_lin/debug/ModuleCache/5QE1M5WG4ATI', but the path is currently '/perfectbuild/.build/debug/ModuleCache/5QE1M5WG4ATI'
1 error generated.
Failed: systemError(1, ":0: error: build had 1 command failures\nswift-build: error: exit(1): /swift-3.1.1-RELEASE-ubuntu16.04/usr/bin/swift-build-tool -f /perfectbuild/.build/debug.yaml\n")
In Perfect Assistant project editor window, press and hold button "Build" and choose "Clean Project", then try building it once more.
Alternatively, press and hold button "Open" then choose "Open Terminal", and run commands below:
$ rm -rf .build*
$ rm -rf *.pins
$ rm -rf *.resolved
Then try building.
If you still couldn't understand what was going on, try opening a terminal window and run scripts below:
$ cd "/Users/hange/Developer/RayWenderlich/Practices/ServerSide_Perfect/hello-perfect-assistant"
$ rm -rf .build*
$ rm -rf *.pins
$ rm -rf *.resolved
Which should perform the same task as the second solution.