`flutter run -d chrome` always closes the chrome after render - flutter

I'm trying to see / develop the flutter app in Web.
However, when I run:
flutter run -d chrome
It can start a chrome browser, and render the page properly; then it would just close, and the process just exit.
I'm also trying:
➜ slide_puzzle git:(release) ✗ webdev serve
webdev could not run for this project.
Could not find a file named "pubspec.yaml" in "$HOME/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-47.0.0".
Here's the project I'm trying to run: <github.com/VGVentures/slide_puzzle>
I'm on Mac, running with latest flutter:
➜ slide_puzzle git:(release) ✗ flutter --version
Flutter 3.3.10 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 135454af32 (2 weeks ago) • 2022-12-15 07:36:55 -0800
Engine • revision 3316dd8728
Tools • Dart 2.18.6 • DevTools 2.15.0

Related

Upgrade Flutter version in project

I'm trying to upgrade Flutter version in my project from 2.8.0 to 3.7.0. If I got it right flutter should be using the default version installed on my machine, but it doesn't. See commands below.
flutter --version
Flutter 3.7.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 9944297138 (4 days ago) • 2023-02-08 15:46:04 -0800
Engine • revision 248290d6d5
Tools • Dart 2.19.2 • DevTools 2.20.1
Still it tries to use previous version
flutter pub get
Running "flutter pub get" in xxx...
Resolving dependencies...
Because xxx depends on flutter >=3.0.0 which doesn't match any versions, version solving failed.
pub get failed
command: "/usr/local/Caskroom/flutter/2.8.0/flutter/bin/cache/dart-sdk/bin/dart __deprecated_pub --color
--directory . get --example"
pub env: {
"FLUTTER_ROOT": "/usr/local/Caskroom/flutter/2.8.0/flutter",
"PUB_ENVIRONMENT": "flutter_cli:get",
"PUB_CACHE": "/Users/yyy/.pub-cache",
}
exit code: 1
you could try :
flutter clean
flutter pub get
if it repeats, maybe you could:
flutter clean
flutter pub upgrade

Xcodebuild fail flutter

I am new to flutter and Xcode, I got a new MacBook pro m1 max and I have a problem with my Xcode build when I try to launch my flutter application, flutter doctor gives me this error:
[!] Flutter (Channel stable, 3.3.8, on macOS 13.0.1 22A400 darwin-arm, locale en-FR)
• Flutter version 3.3.8 on channel stable at /Users/rixez/Developers/medissimo/mobil/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 52b3dc25f6 (8 days ago), 2022-11-09 12:09:26 +0800
• Engine revision 857bd6b74c
• Dart version 2.18.4
• DevTools version 2.15.0
✗ Downloaded executables cannot execute on host.
See https://github.com/flutter/flutter/issues/6207 for more information
and when I try to launch the application here is the message.
2022-11-17 10:24:39.622 xcodebuild[5938:33408] apply_selection_policy_once: avoid use of removable GPUs (via com.apple.dt.xcodebuild:GPUSelectionPolicy->avoidRemovable)
Do you have an idea to get rid of this problem?
I tried to change the GPUSelectionPolicy->avoidRemovable but it didn't change anything
Please try installing Rosetta as described here:
https://github.com/flutter/flutter/wiki/Developing-with-Flutter-on-Apple-Silicon

Flutter and Dart extensions appear to be broken on VSCode

I opened VSCode a few days ago to continue work on a Flutter project, unfortunately, the Flutter and Dart usually take a while to start(2-3 minutes), but this time,the extensions failed to initialize, and I'm left with white colourless code and no access to the tools that come with the extensions(i.e F5 for debug).screenshot of the current state of things
Over the past few days, I have,
Deleted and re-installed the Flutter SDK(forgive me, I cant remember what version it was at before, but now its 3.3.7, Dart 2.18.4)
Deleted and re-installed VSCode(used to be a snap, now a .deb)
Uninstalled and re-installed the Flutter and Dart extensions(multiple times, restarted VSCode each time)
- Ran said project directly from the terminal to be sure I had the flutter tool correctly installed(flutter run and flutter build apk ran fine, with no errors)
Please find the results of 'flutter doctor -v' below
Flutter (Channel stable, 3.3.7, on Ubuntu 20.04.5 LTS 5.15.0-52-generic,
locale en_NG)
• Flutter version 3.3.7 on channel stable at
/home/alabi/snap/flutter/common/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision e99c9c7cd9 (7 days ago), 2022-11-01 16:59:00 -0700
• Engine revision 857bd6b74c
• Dart version 2.18.4
• DevTools version 2.15.0
[!] Android toolchain - develop for Android devices (Android SDK version
32.1.0-rc1)
• Android SDK at /home/alabi/Android/Sdk
• Platform android-33, build-tools 32.1.0-rc1
• ANDROID_SDK_ROOT = /home/alabi/Android/Sdk
• Java binary at: /home/alabi/.jdks/openjdk-18.0.1.1/bin/java
• Java version OpenJDK Runtime Environment (build 18.0.1.1+2-6)
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/linux#android-setup for
more details.
[✗] Chrome - develop for the web (Cannot find Chrome executable at
google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Linux toolchain - develop for Linux desktop
• clang version 10.0.0-4ubuntu1
• cmake version 3.16.3
• ninja version 1.10.0
• pkg-config version 0.29.1
[!] Android Studio (not installed)
• Android Studio not found; download from
https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup
for detailed instructions).
[✓] VS Code (version 1.73.0)
• VS Code at /usr/share/code
• Flutter extension version 3.52.0
[✓] Connected device (1 available)
• Linux (desktop) • linux • linux-x64 • Ubuntu 20.04.5 LTS 5.15.0-52-generic
The CLI command, 'flutter --version' returns
Flutter 3.3.7 • channel stable • https://github.com/flutter/flutter.git
Framework • revision e99c9c7cd9 (7 days ago) • 2022-11-01 16:59:00 -0700
Engine • revision 857bd6b74c
Tools • Dart 2.18.4 • DevTools 2.15.0
All of this leads me to believe the Flutter SDK is installed correctly and the problem is with VSCode and the extensions
Any help is appreciated, thank you!
Make sure that you use official extensions for Flutter/Dart. They are created by Dart Code.
Fixed!
If something in the extension is corrupt you could try uninstalling the extensions and then deleting them from ~/.vscode/extensions (the ones starting dart-code) and then reinstall.
From DartCode's GitHub, read the issue and fix here if you're still confused

How can I run flutter unit test in the browser?

The command flutter test -p chrome /path/to/my/test/file.dart unable to work. What parameters should I use?
[√] Flutter (Channel stable, 2.0.3, on Microsoft Windows [Version 10.0.17763.1817], locale zh-CN)
• Flutter version 2.0.3 at D:\SDK\Flutter
• Framework revision 4d7946a68d (13 days ago), 2021-03-18 17:24:33 -0700
• Engine revision 3459eb2436
• Dart version 2.12.2
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
Being a unit test you should not specify any platform. So the command should only be flutter test /path/to/my/test/file.dart
You only need to run on a specific platform in cases of integration tests.
If u using VScode Follow this steps
1.Step 1 area click anf then
2.Step 2 area Whatever device you want to choose
[][]

Anyone experience vscode very slow after update to 1.30?

What settings to disable to make it fast again?
I'm using VSCode for flutter development. Now very slow when starting the app and during hot reload. Now almost impossible to perform hot reload. I must stop it, do changes then start rather than waiting on hot reload process.
Before update, it was fast but sometimes crash.
I only use Dart 2.21.1 and Flutter 2.21.1 extension. And running on Windows 10.
=======================================================================
The issue seems gone away.
Now I'm using VS Code 1.31.1
flutter --version
Flutter 1.1.8 • channel beta • https://github.com/flutter/flutter.git
Framework • revision 985ccb6d14 (8 weeks ago) • 2019-01-08 13:45:55 -0800
Engine • revision 7112b72cc2
Tools • Dart 2.1.1 (build 2.1.1-dev.0.1 ec86471ccc)
And Dart/Flutter extension is 2.24.0
In your folder, run
flutter clean
this will delete all flutter dependencies and then re-create the project again by using
flutter create YourProjectName
this will create all the flutter dependencies again in your current project, you will not loose your files
The issue seems gone away.
Now I'm using VS Code 1.31.1
flutter --version
Flutter 1.1.8 • channel beta • https://github.com/flutter/flutter.git
Framework • revision 985ccb6d14 (8 weeks ago) • 2019-01-08 13:45:55 -0800
Engine • revision 7112b72cc2
Tools • Dart 2.1.1 (build 2.1.1-dev.0.1 ec86471ccc)
And Dart/Flutter extension is 2.24.0