How to add mac os support to a flutter package project? - flutter

I have tried running the terminal command:
flutter config --enable-macos-desktop
but it gives me error:
The "--platforms" argument is not supported in package template

for an existing project just run
flutter create --platforms=macos .
See also here some official docs from the flutter website:
https://docs.flutter.dev/development/platform-integration/desktop#add-desktop-support-to-an-existing-flutter-app

I have found work around:
copy mac os folder from a new natural flutter project(non-package):
open terminal & run:
cd example/macos
3.run:
pod install
then
flutter run

Related

How to get Flutter SDK path after installing using Homebrew

Installed flutter using homebrew:
https://formulae.brew.sh/cask/flutter#default
I can't find the SDK Path, tried copy and pasting this:
1./opt/homebrew/Caskroom/flutter/2.0.5/flutter/bin/internal/shared.sh,
and, /opt/homebrew/bin/flutter'
but the result shows that the folder specified as the FLUTTER SDK home does not exist, how am I able to find the Flutter SDK path
Type flutter doctor -v in Terminal, the first line will show the location!
If you install flutter using brew install --cask flutter and you are on macOS version 12.2.1. Then flutter is located in the Caskroom folder.
For example, usr/local/Caskroom/flutter/2.10.3/flutter
In my case I installed flutter version 2.10.3 so that is the reason you use flutter SDK located inside the version folder/directory.
find your homebrew futter path
flutter doctor -v
Copy the path under the Flutter stable channel info, eg. • Flutter version 3.0.5 at /opt/homebrew/Caskroom/flutter/3.0.5/flutter
Open vsCode settings, search flutter path, add the path you just copied to these two places:
Dart: Flutter Sdk Path (inside the JSON file)
Dart: Flutter Sdk Paths
Reload vsCode

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

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.

Webdev serve : Can't load Kernel binary: Invalid kernel binary format version. No active package webdev

I want to display my mobile application on the web using Flutter. So, I have done the steps to make it.
But,when use webdev serve in command I get an error.
Can't load Kernel binary: Invalid kernel binary format version.
No active package webdev
I attach the photo below:
How I solve this problem? Thank you
Perhaps you have followed rather outdated instructions. webdev is not used anymore.
At the moment, this instruction is relevant.
flutter channel beta
flutter upgrade
flutter config --enable-web
flutter create myapp
cd myapp
flutter run -d chrome
To add web support to an existing project, run the following command in a terminal from the root project directory:
flutter create .

Flutter SDK Is Not Found In The Specified Location

I'm extremely frustrated right now after I updated Android Studio to have the latest Flutter and Dart Plugins. Now it tells me "No FLutter SDK configured" and when I give it the SKD path it just says, "Flutter SDK Is Not Found In The Specified Location." The Dart plugin works fine.
I have looked for an answer for hours and nothing works. I've downloaded the NDK, flutter doctor works perfectly, and I've tried set the SDK path to pretty much every file inside my flutter folder (inside /Documents).
Any tips?
Go to - Configure -> Tools > SDK Manager > Android SDK > SDK Tools, and search for flutter. You will get flutter SDK for Android.
If you are using Visual studio, also install plugins for flutter in Visual Studio.
» Steps:
Download Flutter SDK: Here
Extract Flutter:
tar xf ~/Downloads/flutter_linux_v1.7.8+hotfix.4-stable.tar.xz
Path export for particular terminal:
export PATH="$PATH:`pwd`/flutter/bin"
Permanent Path export:
Open bashrc file: Go to home directory terminal -> nano ~/.bashrc
Write at end of file:
export PATH=" [PATH_Where_Flutter SDK Extracted] /flutter/bin:$PATH"
example: export PATH="/home/sid/0_aaa_iauro/Flutter/s/flutter/bin:$PATH"
Run the following command to see if there are any dependencies you need to
install to complete setup:
flutter doctor -v
Add Flutter extension to vs-code.
Locate Flutter SDK.
Make New project in flutter:
flutter create Project_name
» Important Links:
Linux Install
Getting Started with Flutter on Linux for Android [Beginner Tutorial]
How To Install And Setup Flutter On Ubuntu 18.04.1 LTS (Bionic Beaver)
Part 2-A: Install Flutter in Windows – Step by Step Guide
Check for path variable (bashrc file):
Flutter – Step by Step Installation on Linux – Ubuntu
If you are using a fresh new Android Studio install as me, try installing missing packages for SDK support in Android Studio as described here: https://ladwhocodes.blogspot.com/2019/02/fix-flutter-sdk-not-found-in-specified-location.html
Go to Menu > Tools > SDK Manager > Android SDK (left side of the dialog) > SDK Tools (tab).
Select 'Support Repository' and 'NDK' checkboxes.
Click OK.
It will prompt you to install some dependencies. Install them.
What happen to me was because there is a space in my android sdk path (which is my username). I copy to C:\android\sdk and problem gone. Probably the space cause issue to NDK thus affect to Flutter sdk.
in my case, it was caused by local changes to the flutter git repo. On command line, everything worked, but in Android Studio it failed to detected the flutter sdk which caused all flutter commands to fail (even though flutter bin dir is in my path). The local changes were probably caused by trying out the beta version of flutter and returning to stable afterwards.
solution: delete flutter dir and redownload (I actually reverted all changes using the git clean command)