New angular dart project fails to start from IntelliJ - angular-dart

I created a new Angular Dart project from IntelliJ but when I try to run the project I get the following output:
/usr/local/opt/dart/libexec/bin/pub global run webdev serve web:61889
No active package webdev.
Dart Dev Server terminated
Is there something I still need to install?

You first need to run
pub global activate webdev
as mentioned in https://pub.dartlang.org/packages/webdev

Related

Gradle (Flutter) does not use the cache

I'm giving Flutter a try, I'm totally new.
I added gradle in:
[project_directory]/android/gradle/wrapper/gradle-wrapper.properties:
distributionUrl=file:///run/media/me/gradle-7.2-all.zip
The first time I ran the flutter run command all dependencies were downloaded. But now when I create a new project, it downloads them again from the internet and doesn't use the previous cache. In fact, if I change something in pubspec.yaml, like adding assets, when I run flutter run it tries to download the internet dependencies again.
Am I missing any settings here?
Flutter 3.1.0 | Dart 2.18.0 | Gradle 7.2 | Linux
for .yaml run 'flutter pub get' command in terminal

Failed to start DevTools: Dart DevTools exited with code 255

I am getting this error code in my Visual Studio Code. How can I fix it?
I am using Flutter v2.5.3.
You can try fixing it by running this in the terminal:
Just copy and paste the below code into the terminal and run it.
dart pub global activate devtools -v 2.8.0
which downgrades the version to 2.8.0 (that works fine). I found the answer on GitHub.
I agree with RandomCoder's answer to avoid executing command
dart pub global activate devtools -v 2.8.0
every time before opening Visual Studio Code.
And also if you didn't know the location of the build folder mentioned by RandomCoder, I found the location after reading it here for the pub cache folder:
By default, this directory is located under . pub-cache in your home directory (on macOS and Linux), or in %LOCALAPPDATA%\Pub\Cache (on Windows). (The precise location of the cache may vary depending on the Windows version.)
After you found it, go to the \hosted\pub.dartlang.org\devtools-2.8.0 directory to copy the build version there and paste it in \hosted\pub.dartlang.org\devtools-2.9.2.
I still didn't know if there is any bad effects of copy pasting it to a newer version folder, but in my case it's working until now.
In my case there wasn’t any build folder in the devtools-2.9.2 folder.
I copied it from 2.8.0 and it now works.
For Android Studio
Close Android Studio
Rn dart pub global activate devtools -v 2.8.0 to downgrade (as suggested in a previous answer)
Open Android Studio
Run your build
For Visual Studio Code
Open Terminal
Run dart pub global activate devtools -v 2.8.0 to downgrade (as suggested a previous answer)
I fix this by:
flutter upgrade
This is an issue coming since yesterday. Maybe they must have updated the Dart engine.
There are two ways which will help you to solve the issue.
Update the Flutter SDK to the latest version and restart your PC:
flutter upgrade
Use the Dart Devtools manually
Run flutter pub global in another terminal. Run devtools and then open http://127.0.0.1:9100
Enter a running application field address of your running application in the Connect: "http://127.0.0.1:60230/J7_wS_YhTuo=/"
You can find this URL in debug console when you run the code.
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:51849/mHlycLJYEWw=/ws
If you are getting any issue regarding the port, then do this in your Flutter project console
flutter run --observatory-port=9100
Once the application starts you can see the message in the console.
If you are getting any server issue in the web browser
then enter
dart devtools
In cmd
Downgrade to devtools-2.8.0
And activate using dart pub global activate devtools -v 2.8.0
These two steps worked in my case
First activate your devtool using this command...
flutter pub global activate devtools
flutter pub global run devtools
And after that, try launching it from Visual Studio Code as described in the documentation: Install and run DevTools from VS Code

Could not resolve project :url_launcher_macos

I create new app in flutter and it's work when I run it, but when I add shared_preferences package, I got this error when I run it
Could not determine the dependencies of task ':url_launcher:compileDebugAidl'.
Could not resolve all task dependencies for configuration ':url_launcher:debugCompileClasspath'.
Could not resolve project :url_launcher_macos.
Required by:
project :url_launcher
Unable to find a matching configuration of project :url_launcher_macos:
- None of the consumable configurations have attributes.
Neither package is compatible with mac
I have faced the same problem and i have fixed this with running following command:
flutter pub cache repair
If this is not working then please try the following:
flutter channel stable then run the commands
flutter clean and flutter upgrade
This worked for me
NOTE:- CLOSE THE FLUTTER PROJECT
Go to Flutter sdk path
Enable the view hidden files in Mac by using CTRL + SHIFT + .
Go to .pub-cache
Go to hosted
Go to pub.dartlang.org
delete this folder url_launcher_macos
Open the project and run app

How do I run dart code that's isolated from my flutter project without creating a new dart project?

So I'm currently following a tutorial on flutter and it showed this nifty way of running dart code in the same project by creating the new file in the app directory instead of the lib folder. I'm using VS code and can't really figure out how to run the file (they used Android Studio). I tried running the file in the terminal and it kept saying
./scratch.dart: line 1: syntax error near unexpected token `('
./scratch.dart: line 1: `void main() {'
Any idea what I'm doing wrong?
Run dart in terminal to Check that you have dart installed globally with global environment variable in your terminal. If not follow this doc to install https://dart.dev/get-dart.
After making sure that you have dart SDK installed globally in your PC, you can run any dart file containing a void main function in a terminal like
~$ dart path_to_file/scratch.dart
Note: Running un terminal will not work if you are working with a package that utilize dart:ui

Flutter - Flutter Version Management (fvm) package not working in windows

I just added the the fvm package to switch the flutter channel from stable to master without downloading sdk components every time when switching flutter channels.
I have followed the step written in readme.md for switching the channel.
I have set the following path in my environment variables.
D:\Program_Files\FlutterSDK\SDK\flutter\bin;
D:\Program_Files\FlutterSDK\SDK\dart-sdk\bin;
C:\Users\User\AppData\Roaming\Pub\Cache\bin;
Now, i have opened my first project in which i want to use "flutter SDK's master channel". But, whenever i try to use the command "fvm use master". It's not working.
It is giving me an error like,
'fvm' is not recognized as an internal or external command,
So, can anyone suggest a solution?
Thanks.
try :
pub global run fvm:main
pub global run fvm:main use VERSION
Hi adding in your path:
%LOCALAPPDATA%\Pub\Cache\bin
More info:
https://dart.dev/tools/pub/cmd/pub-global#running-a-script-from-your-path
In my case fvm commands did not work on Windows even tho I checked everything. It gave missing fvm.exe file and other errors. If you also stuck there you can use this way. Only way I managed to get it work is to use longer commands like these:
flutter pub global run fvm:main list
Seems like all fvm commands:
config Set configuration for FVM
flutter Proxies Flutter Commands
install Installs Flutter SDK Version
list Lists installed Flutter SDK Version
releases Lists Flutter SDK releases.
remove Removes Flutter SDK Version
use Which Flutter SDK Version you would like to use
version Prints the currently-installed version of FVM
Works like this, you just need to add the fvm command to the ending of this - flutter pub global run fvm:main. So add any of them like this form:
flutter pub global run fvm:main releases
flutter pub global run fvm:main install 2.2.0
flutter pub global run fvm:main use 2.2.0
are you add "C:\flutter\bin\cache\dart-sdk\bin" to path?
if you in windows you should run your text editor as administrator as following
In my case Error Message was
Usage Error: Flutter version null is not installed
To fix this:
I have activated FVM by pub global activate fvm;
Printed installed fvm list by fvm list, it should give result as the image below:
Selected which Flutter SDK version to use by running fvm use 1.22.0 (in my case 1.22.0, it may differ according to your desired version) command, It will download SDK if it is not installed yet;
Now you can check is flutter running in your project by running flutter;
Also, you can check if the Flutter SDK version set by calling again fvm list.
The tick means, that version is running in your project.