error with flutter flutter_launcher_icons - flutter

I'm trying to use the error with flutter flutter_launcher_icons plugin to change the launcher icons.
Before I replaced the icons in the folder but this time I want to use this plugin made for that, but I get an error when I run:
flutter pub run flutter_launcher_icons:main
Here is the error:
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
shared_preferences: ^2.0.12
google_fonts: ^2.2.0
flutter_screenutil: ^5.0.3
animated_text_kit: ^4.2.1
shake: ^2.0.0
shake_event: ^0.0.9
flutter_launcher_icons: ^0.9.2
flutter_icons:
image_path_android: "assets/icone-appi.png"
image_path_ios: "assets/icone-appi.png"
android: true
ios: true
I tried to modify the spaces in the writing, but nothing changes.
I thought it would be easier to set up, but I can't find the error.
Thank you for your help

1. Set up the config FIle
add your logo file (ex: logo.png) into assets folder, you have to create the folder first
add flutter_launcher_icons packages in your pubspec.yaml
add a line like this to your package's pubspec.yaml
dev_dependencies:
flutter_launcher_icons: ^0.9.2
flutter_icons:
android: true
ios: true
iamge_path: "assets/logo.png"
2. Run the package
After setting up the configuration, all that is left to do is run the package in the terminal.
flutter pub get
flutter pub run flutter_launcher_icons:main

Related

Flutter app size is big because of google_ml_kit, it almost crossed 150 mb in size

I am creating Flutter paraphrasing app but my app size is too big, I don't know why?
App is used for paraphrasing, the text user can enter text, speak or extract text from file. We translate and paraphrase the text.
I created this for my software house but i don't know why app size is too big. I am not even using static assets still app size is 158MB
name: paraphrase_and_translate
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.17.6 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
speech_to_text: ^5.5.0
google_ml_kit: ^0.11.0
camera: ^0.9.7+1
image_picker: ^0.8.5+3
translator: ^0.1.7
clipboard: ^0.1.2+8
pdf_text: ^0.5.0
file_picker: ^4.6.1
permission_handler: ^10.0.0
flex_color_scheme: ^5.1.0
font_awesome_flutter: ^10.1.0
dio: ^4.0.6
rounded_loading_button: ^2.0.8
language_picker: ^0.4.1
google_fonts: ^3.0.1
flutter_tts: ^3.5.0
simple_speed_dial: ^0.1.7
animated_splash_screen: ^1.3.0
flutter_launcher_icons: ^0.10.0
facebook_audience_network: ^1.0.1
google_mobile_ads: ^2.0.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/images/icon.png"
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
assets:
- assets/images/new.png
- assets/images/parapharse.png
- assets/images/icon.png
This is my pubspec.yaml file.
images are only 2 mbs only
Running "flutter pub get" in paraphrase_and_translate...
Launching lib\main.dart on Redmi Note 8 in release mode...
Running Gradle task 'assembleRelease'...
√ Built build\app\outputs\flutter-apk\app-release.apk (159.1MB).
Installing build\app\outputs\flutter-apk\app.apk...
May be the package google_ml_kit increse the build size.
Try using any specific package that useful to you, mentioned in dependencies of the package.
All these packages are included in the google_ml_kit package. Avoid using unwanted packages.
For instance use google_mlkit_text_recognition if you are using text recognition alone instead of all.
If DevTools is already connected to a running application, navigate to the “App Size” tab.
Check which module is using what size and manage accordingly, also only use required packages and removed unnecessary assets or resize them if possible.
Also: don't use an APK, but an appbundle for Android. It build way smaller binaries. For this, use:
flutter build appbundle
Go to Android > app > build.gradle and set the minSdkVersion to 22
defaultConfig {
applicationId "com.app.app"
minSdkVersion 22 // set this to min 22
targetSdkVersion 31
}

ERROR: NoConfigFoundException Check that your config file `flutter_launcher_icons.yaml` has a `flutter_icons` section

Description of problem: I am trying to add the launcher icon in the pubspec.yaml file but it is showing me this error.
I have tried to even add assets too in the flutter but still not working. When I run flutter pub get no error is shown.
Then I run the command as mentioned in the flutter pub run flutter_launcher_icons:main getting above error.
dependencies:
flutter:
sdk: flutter
retrofit: any
json_annotation: ^3.1.1
provider: ^4.3.1
shared_preferences: ^0.5.8
http: ^0.12.1
flushbar: ^1.10.4
dio: ^3.0.10
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
retrofit_generator : any
json_serializable: ^3.5.1
build_runner: any
flutter_launcher_icons: any
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^1.0.0
# optionally, as transparency is not allowed on app store
# remove_alpha_ios: true
flutter_icons:
android: true
ios: true
image_path: "assets/icons/ic_launcher_square.png"
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter:
It is because of the wrong indentation as I was facing the same problem but now it worked for me
dev_dependencies:
flutter_lints: ^1.0.0
flutter_test:
sdk: flutter
flutter_launcher_icons: "^0.10.0"
flutter_icons:
android: true
ios: true
image_path: "assets/images/cloudy.png"
take care of the spacing behind the lines you are writing
or take a look here

Failed to precompile flutter_launcher_icons:main:

So I tried using flutter_launcher_icons to automatically change the launcher icon of my simple interest calculator app.
This is my code in pubspec.yaml
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.0
flutter_launcher_icons: ^0.8.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: "^0.8.0"
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/icon.png"
flutter:
uses-material-design: true
The Error I got after running flutter pub get &
flutter pub run flutter_launcher_icons:main
Failed to precompile flutter_launcher_icons:main:
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.8.1/lib/utils.dart:1:8: Error: Error when reading '/C:/src/flutter/flutter/.pub-cache/hosted/
pub.dartlang.org/image-2.1.19/lib/image.dart': The system cannot find the path specified.
import 'package:image/image.dart';
^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.8.1/lib/android.dart:4:8: Error: Error when reading '/C:/src/flutter/flutter/.pub-cache/hoste
d/pub.dartlang.org/image-2.1.19/lib/image.dart': The system cannot find the path specified.
import 'package:image/image.dart';
^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.8.1/lib/utils.dart:3:1: Error: Type 'Image' not found.
Image createResizedImage(int iconSize, Image image) {
^^^^^
^^^^^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.8.1/lib/ios.dart:93:1: Error: Type 'Image' not found.
Image createResizedImage(IosIconTemplate template, Image image) {
^^^^^
pub finished with exit code 1
You did not import flutter_launcher_icons package correctly under dev_dependencies. You should not use quotes("). You can edit that part with the following one:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: ^0.8.0
you can change it like that;
flutter_icons:
android: true
ios: true
image_path: "assets/icon.png"
and no need to use that import 'package:image/image.dart'; if you take your image from assets no need to import it like that. you should create a file named assets and put image in it
after that just paste that in terminal.
flutter pub run flutter_launcher_icons:main
In my case the image package was not being correctly downloaded, so I went to ~\flutter.pub-cache\hosted\pub.dartlang.org\image-3.0.8 and cloned the rep from git: https://github.com/brendan-duncan/image
After that the command worked.

Flutter - not able edit pubspec.yaml file

I am trying to add this in pubspec.yaml:
dependencies:
flutter_date_picker: "^0.1.8"
But I'm not able to update packages. I only get an error in Flutter after editing pubspec.yaml file.
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
intl: ^0.15.7 -->**Add Your dependencies like this at pubspec.yaml**

Flutter Error on line 6, column 5 of pubspec.yaml: A dependency may only have one source. sdk: flutter ^^^^^^^^^^^^^

I keep getting
Running "flutter packages get" in flutter_sportters...
Error on line 6, column 5 of pubspec.yaml: A dependency may only have one source.
sdk: flutter
^^^^^^^^^^^^^
When I run my app or Packages Get.
It worked perfectly fine before. Have no idea how to fix this.
Consider you are going to use this package "shared_preferences".
You will get this error in pubspec.yaml. If you did like below.
dependencies:
flutter:
sdk: flutter
shared_preferences: v0.4.2
Indention is important you are accidentally adding shared_preference package below flutter dependency. So the error "A dependency may only have one source"
Correct format below:
dependencies:
flutter:
sdk: flutter
shared_preferences: v0.4.2 #no indention
It throws an error because of Indention. It is important to maintain Indention while adding a dependency in flutter.
Before :
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
english_words: ^3.1.0
After :
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
english_words: ^3.1.0
Hope this will solve your error.
Happy coding!!!
Indentation !!!
Being newbees making silly mistakes. I have written the new dependency inside the flutter root as :
dependencies:
flutter:
sdk: flutter
sqflite:
Instead of
dependencies:
flutter:
sdk: flutter
sqflite:
Comment when you see the difference!!
I was trying to add assets folder to my project. I added it under dependencies which caused the error:
dependencies:
flutter:
sdk: flutter
assets:
- images/
It's not to be added under dependencies. Instead, add it under flutter:
flutter:
uses-material-design: true
assets:
- images/
You can define just like that in pubspec.yaml file
dependencies:
flutter:
sdk: flutter
image_picker: 0.4.1
and flutter packages get you can call via terminal or if you are using Android Studio than options availbale above when you edit pubspec.yaml file.
In terminal go to your project directory and then enter flutter packages get
I solve My problem:
Here my first Code
dependencies
flutter:
sdk: flutter
webfeed: ^0.4.2
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
after I change it
dependencies:
flutter:
sdk: flutter
webfeed: ^0.4.2
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
I thing you must to put your package name in the same number colunm of flutter: and cupertino_icons:
Check indentations as flutter package in pubspec.yaml takes single dependency source.
make sure, the name of your project is not same as any package ,
this too cause for this error
open your pubspec.yaml file
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
country_code_picker: ^1.0.4
Other answers are correct. I would also like to add that I was trying to add shared_preferences and even though my indentation was correct, I was still getting the error mentioned in the question. To resolve it I changed the name of my project as it was also shared preferences
I kept getting this error no matter what I did, including commenting out the new lines. Finally, I put them back in with the correct indentation and ran the program. The problem magically resolved itself. However, the indentation is critical.
I am getting this error due to duplication of a package in dependencies
i.e:
dependencies:
flutter:
sdk: flutter
**cupertino_icons: ^0.1.2**
english_words: ^3.1.5
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
I solved this error by removing duplication then Flutter clean and then Flutter Packages Get.
Its due to indentation: check out correct way
name: flutter_app
description: A new Flutter application.
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
http: "0.11.3+17"
autocomplete_textfield: ^1.6.4
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
I ran into the same problem turns out the name of my app and the package name were same which resulted into this error.
name of the app scrapy and the dependency was also scrapy...
Changed the name and it worked.
After checking all other solutions if the problem still persists
make sure whether the specified library is installed correctly or not. This error also encounter when the library is not installed correctly.