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

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.

Related

pubspec.yaml: Expected a key while parsing a block mapping, uses-material-design: true

I added both firebase_auth: ^4.2.5 and cloud_firestore: ^4.3.2 to the dependecies of the project, but when i try to Get Packages i get this error "Expected a key while parsing a block mapping."
This is pubspec.yaml file:
name: mypocket
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: '>=2.18.6 <3.0.0'
dependencies:
flutter:
sdk: flutter
firebase_core: ^2.4.1
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
firebase_auth: ^4.2.5
cloud_firestore: ^4.3.2
dev_dependencies:
flutter_test:
sdk: flutter
# 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: ^2.0.0
# 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:
uses-material-design: true
assets:
- assets/perigo.png
- assets/logo mypocket.png
- assets/entrada.png
- assets/saida.png
- assets/categorias.png
I already checked and both uses-material-design and assets are in the same vertical line, so this is not the problem.

Can we stop Flutter plugin loading if not use in final build

Seems if a plugin package is included in pubspec.yaml, it will be included in build even not use.
Take my sample project https://github.com/J-Siu/flutter_scroll as example, pubspec.yaml
name: flutter_scroll
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.17.6 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
google_sign_in: ^5.4.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
google_sign_in is a plugin but not imported in any of the source code and there is no dependency using it.
However if you go to the demo page: https://j-siu.github.io/app/flutter_scroll/#/ , open browser inspector -> network, reload the page, you will see https://apis.google.com/js/platform.js is loaded. That is done by google_sign_in initialization.
Question: Other than removing it from pubspec.yaml, is there a way to exclude plugin from final build if it is not imported in source and other dependency?
PS: You can experiment with a plain starting project:
flutter create --platforms web my_testing
cd my_testing
flutter pub add google_sign_in
flutter run (should open chrome)
check inspector -> network with reload
No, i dont think its possible to not use a package thats defined in pubspec during build. You could take a look at packages like
Dependency validator
Where you get to know which packages arent used at all and remove them easily.

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

analysis_options.yaml the included file not found

I have a flutter package that uses effective_dart which is working as expected.
(I've explicitly tested this by adding/removing the include and ensure that warnings come and go as expected.)
I have the effective_dart dependency in my pubspec.yaml as follows:
name: sounds
version: 0.9.1
repository: https://github.com/bsutton/sounds
homepage: https://github.com/bsutton/sounds
documentation: https://github.com/bsutton/sounds/wiki
description: Sounds provide a complete api and Widgets for audio playback and recording. Both iOS and Android are supported.
environment:
sdk: '>=2.1.0 <3.0.0'
flutter: '>=1.17.0 <2.0.0'
dependencies:
device_info: '>=0.4.2+4 <2.0.0'
flutter_spinkit: ^4.0.0
meta: ^1.1.8
path: ^1.6.4
path_provider: ^1.6.7
provider: ^4.1.0
sounds_common: ^1.0.1
uuid: ^2.0.4
flutter:
sdk: flutter
dev_dependencies:
pedantic: ^1.9.0
effective_dart: ^1.2.1
dshell: ^1.0.0
e2e: ^0.5.0
lint: ^1.1.1
pub_semver: ^1.4.4
flutter_test:
sdk: flutter
flutter_driver:
sdk: flutter
flutter:
plugin:
platforms:
android:
package: com.bsutton.sounds
pluginClass: Sounds
ios:
pluginClass: Sounds
The analysis_options.yaml contains:
include: package:effective_dart/analysis_options.yaml
analyzer:
errors:
todo: ignore
strong-mode:
implicit-casts: false
implicit-dynamic: false
The problem is that I keep getting a warning about the include not being found.
If I make a trivial edit (add a commented out blank line) to the analysis_options.yaml file the error goes away for a while but invariably returns (generally after a restart of the ide).
I'm using vs code but believe I've seen it in android studio (although I can't reproduce it now).
The error:
The include file package:effective_dart/analysis_options.yaml in /home/bsutton/git/sounds/analysis_options.yaml cannot be found.
The problem is having no material impact on my project but its just really annoying to have a warning always showing up.
Using the command given below is worked for me. Let you try it in the terminal.
flutter pub add --dev flutter_lints
(restart VSCode if the warning is still shown)
This seems to be a problem with sub projects (your example folder). See https://github.com/dart-lang/sdk/issues/42910
You can try to exclude the example in your root analysis_options.yaml:
analyzer:
exclude:
# workaround for https://github.com/dart-lang/sdk/issues/42910
- 'example/**'
And then add a separate analysis_options.yaml to the example.
If someone is still looking for the answer for the same error, this worked for me.
I have added flutter_lints: ^1.0.4 in dependencies in pubspec.yml file.
And the error gone.
you can try this command
flutter pub add --dev flutter_lints
if didn't work use this command
flutter pub upgrade flutter_lints
It show's up cuz the project import the flutter lints (as it says to encourage good coding practices). Usually, there's a hashtag in front of it that makes it functionless. When there was no hashtag, it was activated and found for the flutter lints package.
Solution:
Add hashtag # in front of it.
Add flutter_lints: ^1.0.4 package in pubspec.yaml file.

Build Runner not running in project folder

I am a newbie in flutter and trying to implement the demo from the "The Boring Show" of Flutter , but right now I am stuck to this issue where I am getting no idea how to get out.
When I am trying to run build runner from the terminal and from the my main project folder , it is not accepting my command. Here is the screenshot I am providing. Can someone please tell me what could be the issue.
Thanks in advance.
EDIT 1:
Here is my pubspec.yaml
name: my_app
description: A new Flutter application.
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
url_launcher: any
built_collection: '>=2.0.0 <5.0.0'
built_value: '>=5.5.5 <7.0.0'
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
dev_dependencies:
build_runner: ^1.0.0
built_value_generator: ^6.3.0
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
Even on Packages getting, I am not getting any kind of error.
name: my_app
description: A new Flutter application.
...
needs to be changed to
name: my_app
description: A new Flutter application.
Indentation in YAML files is significant.