Why doesn't my flutter_native_splash work? - flutter

When I launch the app, the background color works, but the image doesn't show. I have my assets folder in my root directory, and the directory address is matched correctly, but the error persists.
I followed these steps and have this as my pubspec.yaml:
flutter_native_splash:
color: "#000000"
image: assets/icon_500.png
My image size is 500x500 and is a png. (I've tried other sizes as well but ex. 120x120, 200x200 to no avail)
here is my code that runs
void main() {
WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
WidgetsFlutterBinding.ensureInitialized();
runApp(const Main());
FlutterNativeSplash.remove();
}
I ran these terminal commands:
flutter clean
flutter pub get
flutter pub run flutter_native_splash:remove
flutter clean
flutter pub get
flutter pub run flutter_native_splash:create
Here is my pubspec.yaml file
name: todo_time_app
description: A new Flutter project.
publish_to: "none"
version: 1.0.0+1
environment:
sdk: ">=2.18.6 <3.0.0"
dependencies:
cupertino_icons: ^1.0.2
flutter:
sdk: flutter
flutter_local_notifications: ^13.0.0
flutter_native_timezone: ^2.0.0
localstorage: ^4.0.0+1
rxdart: ^0.27.7
dev_dependencies:
flutter_lints: ^2.0.0
flutter_test:
sdk: flutter
flutter_native_splash: ^2.2.17
flutter_native_splash:
color: "#000000"
image: assets/icon.png
android: true
ios: true
web: false
android_gravity: fill
ios_content_mode: scaleAspectFill
fullscreen: true
flutter:
uses-material-design: true
assets:
- assets/
*Edit: I moved the flutter native splash as a dev dependency to see if anything would change. It was initially a regular dependency.
*Edit 2: I've checked my drawables located at "android\app\src\main\res", and the images are generated properly but they are not showing up when I run the app.
*Solution: I added "android_12:" under "flutter_native_splash:" with seperate image and color and it worked.
picture of my issue

Use this Version:
flutter_native_splash: ^2.2.16
it will work

Related

Target of URI doesn't exist: 'package:translations/app_localizations.dart'

I made a clone of this project from Github, the project uses localization to support multiple languages. After I cloned the project I went to pubspec.yaml:
name: converterpro
description: Unit and currencies converter
publish_to: none
version: 3.2.1+37
environment:
sdk: ">=2.15.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
#Needed to store the customizations and the latest currencies convertions
shared_preferences: ^2.0.15
#Needed to open external pages such as GitHub repo, Play Store, etc
url_launcher: ^6.1.5
#Needed for the state management
provider: ^6.0.3
#Needed for translation
intl: ^0.17.0
#Needed for fonts
google_fonts: ^3.0.1
#Needed for navigation between pages
go_router: ^5.0.0
#Needed for Android App Shortcuts
quick_actions: ^1.0.0
#Calculator widget
calculator_widget:
path: packages/calculator_widget
#Needed for updating exchange rates
exchange_rates:
path: packages/exchange_rates
#Needed for app translation
translations:
path: packages/translations
#Needed for unit conversion
units_converter: ^2.0.1
#git:
# url: https://github.com/ferraridamiano/units_converter
#path: ../units_converter
flutter_localizations:
sdk: flutter
dev_dependencies:
test: ^1.21.4
flutter_native_splash: ^1.2.3
flutter_lints: ^2.0.1
msix: ^3.6.3
flutter_test:
sdk: flutter
flutter_native_splash:
# Customize the parameters below, and run the following command in the terminal:
# flutter pub run flutter_native_splash:create
# To restore Flutter's default white splash screen, run the following command in the terminal:
# flutter pub run flutter_native_splash:remove
color: "#eeeeee"
color_dark: "#333333"
image: resources/splash/splash.png
msix_config:
display_name: Converter NOW
publisher_display_name: Damiano Ferrari
identity_name: 39826DamianoFerrari.ConverterNOW
logo_path: resources\images\logo.png
output_name: converternow-windows
publisher: CN=E8FE6044-F04C-422E-AC68-EDA83F6AAFB2
capabilities: internetClient
flutter:
uses-material-design: true
generate: true
assets:
- resources/images/
and clicked on pub get to get all the dependencies listed in the pubspec.
when I went back to my main.dart file to run my app I stumbled upon this error:
The IDE suggested creating a `app_localizations.dar' file, but nothing happened!
Can someone helps me figure out what is going on and how to solve this error
In the README you can find all the instructions to build from source. The project uses Melos for manging the monorepo, so you first need to install it with dart pub global activate melos and then bootstrap it with melos bootstrap. This command retrieve all the packages and generates the translation code. That's because you got that error about translations.

Error on line 18, column 5 of pubspec.yaml: A dependency may only have one source

I'm doing a flutter bootcamp course. The task was to add the english_words dependency but while implementing that I ran into an error in the dev_dependencies as it came from the code stub.
How can I fix this error?
name: xylophone
description: A new Flutter application.
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
# Use Audioplayers dependency version 0.17.4
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- assets/
As for error message, there was an indentation issue. I think you didn't save the pubspec.yaml file. Copy and paste the full snippet and save it then run flutter pub get or use the extension you've used
name: xylophone
description: A new Flutter application.
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
english_words: ^4.0.0
cupertino_icons: ^0.1.2
# Use Audioplayers dependency version 0.17.4
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- assets/
You can use the pubspec.yaml given by #yeasin Sheikh.. Also if you unfamiliar with using pubspec. The easiest way to add a package is to run
flutter pub add english_words
in terminal.
This will add the latest version of english_words package to your pubspec with proper indentation.

FlutterAppRequiredException: The current directory does not appear to be a Flutter application project

i have install firebase tools for implement it in flutter, i followed all the instruction but when i run "flutterfire configure" this error appears (FlutterAppRequiredException: The current directory does not appear to be a Flutter application project.)
You need to first redirect to your application path in CLI
cd app_name
Try again flutterfire configure command after that.
You must make sure that in your pubspec.yaml the following lines are on the start of dependencies place, ex:
dependencies:
flutter:
sdk: flutter
Make sure your pubspec.yaml file is well defined and correct.
In my case, I had erased after dependencies
flutter:
sdk: flutter
...
The correct format may be in flutter 3.3.0 Flutter and the pubspec file
name: myapp
version: 1.0.0+1
publish_to: none
description: A new Flutter project.
environment:
sdk: '>=2.18.0 <3.0.0'
dependencies:
cupertino_icons:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
assets:
- assets/
uses-material-design: true

error with flutter flutter_launcher_icons

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

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.