Is it possible to run the terminal command in dart?
I want to run this command using custom command on the terminal.
custom command like this
dart run build-dev(build-dev is a script file)
full command in build-dev file
rm pubspec.lock && flutter clean && flutter pub get && flutter pub upgrade && flutter build apk --flavor dev -t lib/main_dev.dart
Found the answer myself.
install this package.
dart pub global activate flutter_scripts
(if you use mac os, you should setup mac shell)
you can run the same command in Flutter by using the flutter run command. Here's an example of how you can do this:
Open the pubspec.yaml file in your Flutter project.
Add a new script to the scripts section of the file:
scripts:
build-dev: flutter build apk --flavor dev -t lib/main_dev.dart
Run the script using the flutter run command:
flutter_scripts run build-dev
This will execute the flutter build apk command with the specified arguments. You can then run this script anytime by using the flutter run build-dev command.
You're asking for trouble running a dart script in a package that deletes the lock file and runs clean and pub get.
Also, pub get then pub upgrade is redundant. Just run pub upgrade.
Just make this a shell script (or batch file)!
Related
I want to write a script to call flutter_gen package from CLI using fluttergen -c pubspec.yaml command. But the only way I know to do it is run dart pub global activate flutter_gen firstly.
This approach requires the user of my script to ensure that /.pub-cache/bin directory is added to PATH. To prevent such extra work, I want to find a way to run it "locally" (i.e. without global activation).
For know I use this bad workaround:
dart pub global activate flutter_gen
fluttergen -c pubspec.yaml
dart pub global deactivate flutter_gen
How can I run fluttergen -c pubspec.yaml command without dart pub global activate flutter_gen command?
i'm having some problems while compiling my flutter app for Android.. I've only 3 assets and a couple packages added, but when I try to compile, I got this:
√ Built build\app\outputs\flutter-apk\app-release.apk (158.3MB).
Any idea?
Flutter build log (running flutter build apk)
PS C:\\Users\\Admin\\Desktop\\Fictix\\Don't Touch This\\app\\dtt_app\> flutter build apk
Building with sound null safety
First of all, you can try clearing the cache via terminal.
flutter clean
This command will delete few temporary folders, specially "build/", ".dart_tools/" and ".packages/".
You can also run the following code from the terminal before the build phase of your application.
flutter build appbundle --target-platform android-arm,android-arm64
Of course, it is not a 100% method, but it can work in reducing your application size.
You can follow the steps below to clear it by Android Studio.
Tools > Flutter > Flutter Clean
Make your app with no sound null safety
From Terminal Run This Command
flutter build apk --split-per-abi --no-sound-null-safety
or
flutter build apk --release --no-sound-null-safety
If your problem still persists
// #2.9 in the top remove the parameter from Const app_name();
Run --no-sound-null-safety from terminal
Edit your Configure File and write in Additional run args:- --no-sound-null-safety
When I run my bitbucket pipeline for my project im getting an error during flutter test:
/root/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.24.0/lib/src/firebase_app.dart:18:25: Error: Member not found: 'FirebaseAppPlatform.verifyExtends'.
FirebaseAppPlatform.verifyExtends(_delegate);
^^^^^^^^^^^^^
When I run flutter test in my terminal I don't have these issues.
My pipeline script is:
Build Setup
flutter clean
flutter pub get
flutter pub run build_runner build
bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-dart/main/install.sh)
flutter test
Because there are some breaking change of firebase_core_platform_interface that do not comply with semantic versioning:
https://github.com/firebase/flutterfire/issues/9806
You need to overwrite this library:
Root cause
You are update or installing only a subset of the Firebase plugins (firebase_core, firebase_analytics,...)
Solution
Solution 1: (preferred) Updating to the latest version with flutterfire update check the docs here. But it is not easily because your project will have a lot of packages dependencies to each other like flutter version 2 or 3, so on. Anyway, it is long term solution.
Solution 2: (Fix to run)
You can add to your pubspec.yaml
dependency_overrides:
firebase_core_platform_interface: 4.5.1
Solution 3: (Fix to run)
Update dependencies with this below command line:
flutter pub upgrade --major-versions
Finally, Run the project again by following stuffs:
flutter clean
flutter pub get
cd ios && rm -f Podfile.lock
cd ios && pod install --repo-update
flutter run
That's it!
Run "flutter pub upgrade --major-versions"
run this
flutter pub upgrade --major-versions
than run this
flutter upgrade
I changed my flutter version via flutter channel master. This changed automatically my pubspec.lock.
In my case, restoring previous version of pubspec.lock solved the problem (pug get needed).
I am using Mac OS. i am trying register my project in firebase and use Crashlytics in firebase to check if any crash occurs in my app I had used
curl -sL https://firebase.tools | bash
command to install flutter tools it worked fine after that I tried to run
flutterfire configure
command but it throws
zsh: command not found: flutterfire
I know that I must set $path variable but to set path variable I don't know where is my flutter tools has installed in my Mac. kindly help me to set $PATH variable
run before dart pub global activate flutterfire_cli
Once you run the following command
dart pub global activate flutterfire_cli
you should get the following output
The output is telling you the executable is not on your path variable
export PATH="$PATH":"$HOME/.pub-cache/bin"
Either run the export command in your terminal
OR
Add the command to your .zhrc file
hey guys i have error after using command : flutter pub run build_runner build
error message :
C:\Users\matin\AndroidStudioProjects\mosito>flutter pub run build_runner build
Could not find a file named "pubspec.yaml" in "C:\Users\matin\Documents\flutter\.pub-cache\hosted\pub.dartlang.org\async-2.8.1".
pub finished with exit code 66
i try flutter pub upgrade and a lot of things from google but problem not fixed
NOTE: im new to flutter i want use this command for making .g.dart file for my models thanks for your attention
I think may be you are not in your project directory. Suppose you have a project name A in myfolder in C drive of your computer. First goto myfolder with terminal. after that try below code to build the project...
flutter packages pub run build_runner build --delete-conflicting-outputs
Turn on Your Terminal and Run
flutter doctor
if it is showing
Could not find "flutter"
Then you need to install flutter Correctly You Can check :
https://docs.flutter.dev/get-started/install/windows