how to rename package name in a flutter project - flutter

I have added rename: ^2.0.1 and gave pub get. then I run this command
pub global run rename --bundleId com.hit.fantomcarpentry
but Im getting below error,
'pub' is not recognized as an internal or external command, operable
program or batch file.
how to correct this. I want to change my package name.
current package name
package="com.hit.fixing_to_do"

Try this command, you should include flutter before pub in command and make sure you are in the project directory:
flutter pub global run rename --bundleId com.hit.fantomcarpentry
If not work follow alternative solution:
You can use change_app_package_name.
To use this, add this package in pubsec.yaml
dev_dependencies:
change_app_package_name: ^1.0.0
Not migrated to null safety yet? use old version like this
dev_dependencies:
change_app_package_name: ^0.1.3
then run this command in project directory:
flutter pub get
flutter pub run change_app_package_name:main com.new.package.name

Related

Flutter - how to use packages outside pub.dartlang.org

I'm trying to use flutterfire_ui for authentication in a flutter app. The developer (invertase) has committed a pull request 9343 on github that fixes some problems. I have pulled it into a local GIT folder. It includes some reorganization of folders, including a package name change - firebase_ui_auth instead of flutterfire_ui. I have changed my local pubspec.yaml to use all the firebase packages in PR 9343 but I get an error with "pub get" as follows that I am unable to resolve.
Running "flutter pub get" in firebase_with_flutter...
Because every version of firebase_ui_oauth from path depends on firebase_ui_auth from hosted and firebase_with_flutter depends on firebase_ui_auth from path, firebase_ui_oauth from path is forbidden.
So, because firebase_with_flutter depends on firebase_ui_oauth from path, version solving failed.
pub get failed (1; So, because firebase_with_flutter depends on firebase_ui_oauth from path, version solving failed.)
In pubspec.yaml I have entered an explicit path to all of the PR9343 firebase packages
firebase_core:
path: C:/GP/project/git-remote/flutterfire/packages/firebase_core/firebase_core/
cloud_firestore:
path: C:/GP/project/git-remote/flutterfire/packages/cloud_firestore/cloud_firestore/
firebase_auth:
path: C:/GP/project/git-remote/flutterfire/packages/firebase_auth/firebase_auth/
firebase_ui_auth:
path: C:/GP/project/git-remote/flutterfire/packages/firebase_ui_auth/
firebase_ui_oauth:
path: C:/GP/project/git-remote/flutterfire/packages/firebase_ui_oauth/
In main.dart android studio reports "invalid URI" for this import
import 'package:firebase_ui_auth/firebase_ui_auth.dart';
https://github.com/firebase/flutterfire/tree/master/packages/flutterfire_ui
Does anyone have any idea what I am doing wrong?
If I add explicit paths to the pubspec.yaml files in my local git repo just as I have for my own pubspec.yaml file then it works and pub get runs without error. So now I have this
firebase_auth:
path: C:\GP\project\git-remote\flutterfire\packages\firebase_auth\firebase_auth\
instead of this
firebase_auth: ^3.6.2
How come it works for the Invertase developer without using path settings and not for me. As well as that, the firebase_auth package is in a "deeper folder"
C:\GP...\packages\firebase_auth\firebase_auth\ than it was before and if I leave off the inner \firebase_auth from the path it doesn't work.
Maybe I'm supposed to use the git mechanism instead of an explicit path setting.

Could not find a file named "pubspec.yaml" when auto generating code with build_runner

After I have updated Flutter to v1.22 using code generation with build_runner was not working. I was told that the proper command to use in this version was:
dart pub run build_runner watch --delete-conflicting outputs
However, I receive the following error:
Could not find a file named "pubspec.yaml" in "C:\Users\jpiab\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\_fe_analyzer_shared-2.2.0".
I have no idea why it is looking for pubspec.yaml in that folder, since that folder is not the current working directory.
--- EDIT ---
The file exists in path:
C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-2.2.0
dart is just looking for it in the wrong place. Any ideas on how to fix it?
I solved for me. I use Android Studio in Ubuntu 20.04.01 LTS.
Firstly run this command:
flutter pub get
After run this command:
flutter packages pub run build_runner build
Or:
flutter packages pub run build_runner watch
Source: https://github.com/flutter/flutter/issues/50092
Deleting the .pub-cache folder.
and then run pub get
Edit:
If above method won't work then delete the folder
C:\Users\jpiab\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org_fe_analyzer_shared-2.2.0
and then run pub get from within your project directory.
That same error I had and I resolved it by aligning my dependencies. Check if your build_runner is in the same line as flutter_test if you added it to dev_dependencies.
Error Corrected
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: [latest]
My Error
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: [latest]
I fixed it by changing the environment variable PUB_CACHE to the right folder.
TL;DR
Make sure you run the flutter command from the project's root directory.
As you can see, Running the command from a specific folder reproduces this error while everything works as expected from the project's root directory.

Error: Could not resolve the package 'rxdart' in 'package:rxdart/rxdart.dart'

I created an example project inside a my flutter package and inside my example project i did:
dependencies:
flutter:
sdk: flutter
my_package:
path: ../
my_package used rxdart and i received an error after run my example project
Error: Could not resolve the package 'rxdart' in
'package:rxdart/rxdart.dart'.
I ran flutter packages get but the error is still here.
I just ran into the same issue. To solve it follow these steps:
Kill your app if it's running
Run flutter clean in both your main project directory and your my_package directory
Run flutter pub get in both your main project directory and your my_package directory
Now when you build your app you should be all set.
Check first, if you added rxdart package to your pubspec.yaml as shown below:
dependencies:
flutter:
sdk: flutter
rxdart: ^0.24.1
Run flutter pub get

Error in terminal while running flutter pub get: Response:

I am new to flutter and SO, I tried this Flutter force higher package dependency version,
My code was
dependencies:
intl: ^0.15.0
I replaced it with
dependency_overrides:
intl: ^0.16.0
But I still get this error
$ flutter pub get
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
Do not run this command from the root of your git clone of Flutter.
This isn't a pubspec issue. You're simply executing the command from the wrong directory.
cd into the directory where your flutter project files are. That will be the folder that contains other folders like, build, android, ios, lib along with the pubspec.yaml file. Run flutter pub get from there.
Go to the root of your project, where the lib and other directories exist. Then run the command. The best is to use the terminal of your code editor as the path would be same as root of your project in there.

How to update pub package webdev for flutter web

when I try to "serve" my flutter web app
I'm getting this error:
This version of webdev does not support the build_daemon protocol
used by your version of build_runner. A newer version of webdev is
available which supports your version of the build_daemon. Please
update.
how do I update webdev ?
"pub global" seems to offer only "activate"/ "deactivate"
and "pub upgrade" is only looking into the pubspec.yaml file
any idea?
Oh... I just run "pub global deactivate " and then "pub global activate ".
Anyway I opened an issue on github suggesting to add the feature "update".
I hope this easy solution might help you,
feel free to follow up the issue.
Adding build_daemon: ^1.0.0 in dev_dependencies: of .yaml file fix my error
Do not use a global version, but use a per-project version.
To ensure running webdev on your project always works, include the version of webdev it requires in the pubspec.yaml file:
dev_dependencies:
webdev: ^2.7.9
...
And run it using:
$ dart run webdev ...
This ensures the correct version of webdev is installed when dart pub get is run, and that particular version is used for the project.
This avoids having to update the global version when things change. Running dart pub global deactivate webdev and dart pub global activate webdev is unnecessary work.
Globals are bad. Using "dart pub global activate ..." installs only one version of webdev, which may become out-of-date with your project (as you've discovered). Or you might have multiple Dart projects, and they require different versions of webdev. The above approach uses a per-project version of webdev, ensuring it is always the correct version for the project.
I got the same problem now when I followed this tutorial https://medium.com/flutter-community/flutter-create-and-deploy-a-website-from-scratch-4a026ebd6c, but I didn't get pass the error by running flutter pub global activate.
Here is what i configured in my computer
run: pub get
run: webdev serve
dev_dependencies:
build_daemon: ^1.0.0
build_runner: ^1.4.0
build_web_compilers: ^2.0.0
Wish this will fix your issues.
I had to use the following command to update webdev
flutter pub global run webdev deactivate
and then
flutter pub global run webdev activate