Add flutter web and desktop to existing flutter (android/ios) project in android studio - flutter

I know it maybe still early but I want to try and use full flutter existing cross-platform support in one project. Stability is not my main concern.
I have started a flutter project in android studio. Naturally I have (android/Ios) going smoothly. But I would love to add Web and desktop to the same project.
Please help me with and direction, or if there is solution any one has created however much experimental.

There is a migration guide for web here. I got it up and running on a very basic existing app.
Best way is to do it in a separate branch since it requires changing packages and I even deleted .packages and pubspec.lock files first. Then I ran pub get (not flutter packages get) to download the required packages and run some precompilers.

Related

I get this error in my flutter app. migrate this app to the V2 embedding

I get this error in my Flutter Project,
C:\src\flutter\bin\flutter.bat --no-color pub get
Running "flutter pub get" in source_code... 34.3s
This app is using a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to migrate this app to the V2 embedding.
Take a look at the docs for migrating an app: https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
The plugin firebase_core requires your app to be migrated to the Android embedding v2. Follow the steps on https://flutter.dev/go/android-project-migration and re-run this command.
Process finished with exit code 1
Flutter Embedding Error
Since Flutter 1.12 the way how Flutter plugins communicate with the native Android side has been improved. Allowing plugins to better integrate with the native Android lifecycle.
Some plugins support both the new and the old structure, however many plugins (like firebase_core) dropped support for the legacy structure to ensure optimal integration with the Android system.
Apps created using Flutter 1.12 and higher automatically generate the correct Android integration logic, however Flutter applications created with an earlier version of Flutter need to be manually migrated. There are two options to fix this for your app:
The easiest solution is to delete the android folder in your project and let Flutter (using Flutter 1.12 or higher) recreate it for you by running the following command in the root folder of the Flutter project: flutter create --platform=android . (don't forget the . at the end of the command). You should only do this if you haven't made any custom changes to the Android code and of course make sure to make a backup first.
The more safe option is to manually migrate the Android project using the instructions provided on the GitHub Wiki page mentioned in the error message.
When following the instructions on the GitHub Wiki page make sure to keep an eye on all the details. Personally I forgot to update the <application android:name="MyApp" to the recommended <application android:name="${applicationName}" which resulted in the same error you are reporting.
What helped me was to create a new "dummy" application with the latest version of Flutter (for example flutter create --platforms=android test_app) and compare the files in the Android folder with the files of my current App and make changes where necessary.

Flutter package's own import target URI does not exist

I have a Flutter project that I started as a package in order for it to speak to platform specific native code. I've updated several packages lately along with flutter and my
import: package: mypackage/mypackage.dart
is no longer working. The dart analysis says the target URI doesn't exist and none of the of solutions for outside packages seem to work for me. Any ideas on how I can correct this issue?
Follow these steps:
flutter clean
flutter packages get
flutter packages upgrade (Optional)
Restart Android Studio or Visual Studio
I corrected the issue by downloading the clone that I recently pushed to git. I read through several entries that it could be related to pushing to git - especially is you forced a push.
If this is your situation 1) archive your local working copy 2) clone your project back from github/gitlab 3) run flutter packages get and flutter clean
If you understand how force pushing your project to git may effect package URI dependencies, please elaborate.

How do I access the same flutter projects from different computers (not at the same time) (Android studio, flutter)

How can I access my flutter projects from different computers?
I use Android studio to build my flutter projects and currently I am working on an app, and I would like to access this project while at home and at my workplace. Is there a way to save the project in cloud or elsewhere to be able to access it from any device. I have tried to copy and paste the project, it does seem to work, but there is so much issues that I have to take care of before I can start working on the app again.
Thank you for any help.
There are many version control systems available for this purpose.
Here are a few you can use:
-GitHub
-GitLab
-BitBucket

How to use both Flutter stable and dev SDK on the same machine?

I'm working with Flutter to make a Mobile App using the stable Flutter SDK release. But I also want to try Flutter Desktop and Flutter Web that are not part of the Flutter stable channel yet, but are present on the Flutter dev channel.
My question is... How can I try Flutter Desktop and Flutter Web without override the Flutter stable release on my machine?
You'll need to setup alias to switch between different environments easily.
See here a detailed article for that.
I found this Dart package called Flutter Version Management that does exactly what I want.
As the docs says:
Flutter Version Management: A simple cli to manage Flutter SDK versions.
Features:
Configure and use Flutter SDK version per project
Ability to install and cache multiple Flutter SDK Versions
Fast switch between Flutter channels & versions
Dynamic SDK paths for IDE debugging support.
Version FVM config with a project for consistency across teams and CI environments.
Set global Flutter version across projects
https://github.com/leoafarias/fvm
Now I just need to add FVM_HOME/default/bin to the PATH and FVM will take care of everything...
Two solutions
Put the installation files in two different directories one with stable and the other dev and add one of them to the path then you can change the path variable when needed to use the other channel.
Put the flutter repository file in two different directories one with stable and the other with dev then,
add the first installation to the path then add an alias to point to the second installation directory.

Workflow to upgrade a Flutter project/application

I have several Flutter projects that I have been working with for some time. Some a rather new and others are older. I constantly upgrade my Flutter SDK and switch between stable and beta channels. Everything works but the newer projects have different file layouts, for example .gitignore in android/ios folders, new XCode config files etc.
How do I update an older project to the new layout so as if it was just generated with flutter create?
Also there is this .metadata file generated which makes no sense to me. It never gets updated and only has it's project_type read by flutter_tools during flutter create. What is this for, why is it not being updated to the correct channel/rev?
Due to my research for the former question, I have run flutter create . in an existing project which generates some new files. Is this the only way, together with manually diffing to a new pristine project? And why is the .metadata file still outdated?
If anyone has some insights or documentation links regarding this, that would be great. I didn't find anything.
Update:
Apparently one can update the initially generated Flutter configuration files by re-running flutter create ..
Old:
Somewhat answering my own question here.
On March 3rd a commit was added to Flutter that added the notion of migrations to the iOS template/configuration (https://github.com/flutter/flutter/commit/e491544588e8d34fdf31d5f840b4649850ef167a).
These migrations take care of bringing the XCode configuration files to the latest version.
This commit has been ported back until Flutter 1.15.x.
This a great step forward. Hopefully similar migrations will be added for Android configurations and basic project files in the future.