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.
Related
I am getting an error like this:
Because every version of flutter from sdk depends on collection 1.16.0 and syncfusion_flutter_datagrid >=19.1.54-beta <20.1.48 depends on collection >=1.9.0 <=1.15.0, flutter from sdk is incompatible with syncfusion_flutter_datagrid >=19.1.54-beta <20.1.48.
So, because datagrid_json_datasource depends on both flutter from sdk and syncfusion_flutter_datagrid ^19.1.65-beta, version solving failed.
pubspec.yaml:
name: datagrid_json_datasource
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
http: ^0.12.0
flutter:
sdk: flutter
intl: ^0.17.0
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
syncfusion_flutter_datagrid: ^19.1.65-beta
flutter:
uses-material-design: true
i try too chenge sdk version when i change to sdk version and also try flutter clean and flutter pub get.
Try updating to newer version of syncfusion_flutter_datagrid.
Add to pubspec.yaml:
dependencies:
syncfusion_flutter_datagrid: ^20.3.52
Then run flutter pub get
I tested this with multiple Flutter versions and the one you should use is the 2.2.0 because this is the version which contains the Collector 1.9.0, you cannot use another version of Collector or override it because dart:Collector contains different data structures that are used in the code base of flutter.
This is the pubspec.yaml that works for me for Flutter 2.2.0
Hope it helps you :)
name: test_datasourcee
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
syncfusion_flutter_datagrid: ^19.1.65-beta
flutter:
uses-material-design: true
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.
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.
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
I am trying to use a source generation package that I have written myself called animated_widget_generator. the annotations package is called animated_widget_annotations and the app I am trying to use it for is called example_usage.
I added the necessary packages to my dev_dependencies. here is my pubspec.yaml:
name: example_usage
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
animated_widget_generator:
path: ../animated_widget_generator
animated_widget_annotations:
path: ../animated_widget_annotations
build_runner: ^2.0.4
flutter:
uses-material-design: true
but when I try to run the app on my phone, it gives me the following errors:
Launching lib\main.dart on ONEPLUS A6003 in debug mode...
√ Built build\app\outputs\flutter-apk\app-debug.apk.
E/flutter (17052): [ERROR:flutter/shell/common/shell.cc(242)] Dart Error: error: import of dart:mirrors is not supported in the current Dart runtime
E/flutter (17052): [ERROR:flutter/runtime/dart_isolate.cc(169)] Could not prepare isolate.
E/flutter (17052): [ERROR:flutter/runtime/runtime_controller.cc(401)] Could not create root isolate.
E/flutter (17052): [ERROR:flutter/shell/common/shell.cc(571)] Could not launch engine with configuration.
Exited (1)
there are other questions on Stack Overflow about this error but they are always about some third party package and not about a custom source generation package and it doesn't seem like any of the answers to those questions are relevant to me
EDIT: pubspec.yaml for animated_widget_generator and animated_widget_annotations:
name: animated_widget_annotations
description: A new Flutter package project.
version: 0.0.1
author:
homepage:
environment:
sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.17.0"
dependencies:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
name: animated_widget_generator
description: A new Flutter package project.
version: 0.0.1
author:
homepage:
environment:
sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.17.0"
dependencies:
flutter:
sdk: flutter
path: ^1.8.0
source_gen: ^1.0.2
json_serializable: ^4.1.3
animated_widget_annotations:
path: ../animated_widget_annotations
dev_dependencies:
flutter_test:
sdk: flutter
pedantic: ^1.11.0
build_runner: ^2.0.4
flutter:
You are receiving this error because the package dart:mirrors package is not available with flutter.
Do check these conversations on google groups and github for more info.
An alternative package called reflectable is available for reflection, however it has limitations at this time.
It is a very common problem with upcoming flutter developers. The main reason is that the flutter and dart are getting updated quickly. Sometimes after their upgradation let's say after this latest version of Flutter 2.2, you can see on their github that some packages are removed from their stable mode in order to work on them to make them more efficient. So, you can't access those packages. Make sure that you either find an alternate package for the same task or try to change the version number of the dependency to a lower number which might work because of backward compatibility. pubspec.yaml can be very difficult to understand if you have version problem because it will tell you that the dependency doesn't exist but won't tell you the reason.