How come "flutter create ." adds desktop support? - flutter

I created a Flutter project within Android Studio, and then later found out that Flutter supports desktop. After searching the web, I did things like switching to "dev", adding config for desktop, etc. But when I tried to ran it, I got "No Windows desktop project configured", even though I enabled the configuration.
The documentation page had
To add desktop support to an existing Flutter project, run the following command in a terminal from the root project directory:
flutter create .
This adds the necessary desktop files and directories to your existing Flutter project.
But what is the meaning of .? How come that . means "adding desktop support"?

The command to add desktop support are those one:
flutter config --enable-windows-desktop
flutter config --enable-macos-desktop
flutter config --enable-linux-desktop
Once you used them, you change your flutter config.
Then, the usage of flutter create . simply mean "Create a new flutter project in my current folder".
If you're already in a Flutter project, it will just "recreate" your project by adding the new support for Desktop since you specify in your flutter config.

flutter config --enable-[windows,linux,macos]-desktop
flutter create .
if there is some error with second command, remove - sign from parent folder name, and run this command:
flutter create --org com.example.myapp .

Run this command it works fine for me.
run
flutter config --enable-windows-desktop
then run
flutter create .
if flutter create . generate error, probably there is - in your root project directory.
for example it will generate error if your project is like below
Alewa-Stock
to work it fine rename your project directory like below
alewa_stock
then run the following command
flutter create --platforms=windows --org=com.alewa.store .
*
NB: Please change the name according to your preference.

flutter create --platforms=windows,macos,linux .
you can use this line instead

Related

Cannot create a project within the Flutter SDK. Target directory 'C:\src\flutter\test_instalasi_flutter' is within the Flutter SDK at 'C:\src\flutter'

[test_instalasi_flutter] flutter create --template app --overwrite .
Cannot create a project within the Flutter SDK. Target directory
'C:\src\flutter\test_instalasi_flutter' is within the Flutter SDK at
'C:\src\flutter'. exit code 2
hi! i'm newbie, please help me.
when creating a new Flutter in visual studio code, the library folder doesn't show up. But when I create a new Dart library it exists and appears, how do you flutter it ?. thank you
Just change your directory different than the FLUTTER SDK directory (don't use this: C:\src\flutter)
Just change the location where you're saving the project( Save it to a new directory) and you'

Could not create task ... this and base files have different roots

I've built an app with Android Studio and Flutter and wanted to generate a signed APK.
When I go to Tools->Flutter->Open Android module in Android Studio, it starts to build the project.
But after some time I get this Error and I don't know how to change the roots or what to do.
It seems like the problem are just two packages (url_launcher and shared preferences)
My Project is on my hard disk F:
and the flutter folder is on my hard disk C:
Error Message "Could not create task..."
Is this maybe because my project is on F: and the flutter folder with the packages in C: ?
How can I change the flutter folder to F: ?
I fixed mine by moving the project directory to the same drive. My project was stored in E:\ so, I moved it to C:.
My answer is almost the same as rvr93's answer but I did not add anything to the environment variables.
Create a directory in the same drive as your project and add PUB_CACHE environment variable. Run flutter pub get.
This worked for me.
I had your same issue, Gradle couldn't sync the android module, I solved it by deleting the android/ directory from the Flutter project, then recreate it using the command flutter create --platforms android .
Notice the "." at the end of the command it's part of it, it means create the Android project in the current directory.
As a workaround, you can do the following steps -
run flutter clean
do the Gradle sync without flutter pub get and make necessary changes to
native android code.
do pub get and run the app.
I have the same issue,
it seems the flutter project and the SDKs are in different prtitions of the hard disk
just go to the project root and run flutter clean
then go to the android folder and delete the .gradle folder
then back to the project root and run flutter pub get
and rebuild the app
As a workaround, you can do the following steps :
Open a terminal.
Run flutter clean.
Do the Gradle sync without flutter pub get and make necessary changes to native Android code or click on try again.
Do flutter pub get and run the app.
You will see that the SHA1 has been generated.
I faced the same issue in my android project after upgrading gradle.
My project was in my D drive, and I had set the destination folder for the generated apk in my desktop, which is in C drive. I changed the destination folder to a folder in D drive, and the issue got resolved.
I was facing the same issue all I did was to go build.gradle file in android folder and then change the following code as follows
dependencies {
//CHANGE THE Version in YOUR BUILD.GRADLE FILE
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
This is a temporary solution - track status here

I cannot initialize Flutter for web after adding flavors to my project

I have a Flutter project that currently builds for iOS and Android. I created the project around Flutter v1.9 or so. Since creating the project, I have added flavor support to my project (dev, prod) via the guide found here
However, after having done this, it doesn't seem like I am able to add web support to my project. Following Flutter's official instructions to enable web for a pre-existing project, I try to run flutter create . in the root directory of the project. When I do this I get the output:
The Xcode project defines schemes: dev, prod You must specify a --flavor option to select one of the available schemes.
So I try to run: flutter create . --flavor=dev and get Multiple output directories specified. Try moving --flavor=dev to be immediately following create
Soooo, I try: flutter create --flavor=dev . and get Could not find an option named "flavor".
Does anyone know how I can initialize web for this project? Thanks.
You need to do the following:
Goto root folder and rename manually ios folder temporarily to something like ios1
Goto terminal and make sure you are standing in root, then run this line:
flutter create --platforms=web .
Return to project folder and rename back manually ios1 to ios
Done

Flutter does not working even after Path update

I tried to install flutter, i followed excat steps in official docs. Installed SDK from github and added path to my bashrc file, As shown below picture, even though path successfully updated, flutter commands not recognizing and not working.
https://imgur.com/a/WfQ88J0
1
I recommend clearing the android-studio-dir and android-sdk settings, and let flutter automatically detects their path instead: This works for me .
flutter config --android-studio-dir=""
flutter config --android-sdk=""

New Flutter projects results in a blank project

This type of steps follws for flutter setup :
1)download latest version of v1.7.8+hotfix.4 this below link
https://flutter.dev/docs/development/tools/sdk/releases
2)my flutter store in this url : C:\src
3)set enviroment variable C:\src\flutter\bin
4)Android studio download and install.
5)install plugin flutter & dart...in android studio...than after restart IDE.
6) than after i have to start a new flutter project
-flutter_demo (project name)
-C:\src\flutter (SDK path)
-C:\src\flutter_project (project location)
my issue is this when i have to create new flutter project only create blank folder in this location [[C:\src\flutter_project]] no any other process.
what is my issue??? i need to help???
this step follow another PC in window 7
--work properly
-but in my pc not working.
-my pc os is also window 7
I also faced with the same problem about creating flutter blank project. In my case, I check the installation steps and all are correct.
The answer is in User Environment Variable Path, there is also old flutter/bin path that I had tested before.
I deleted the old flutter bin path and also in System Environment Variable Path. Then, I can create flutter project and run futter doctor successfully.