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.
Related
I am currently trying to implement localization in my Flutter App but whenever I try to add the dependency for flutter_localization, I get the following error Message:
Because the timer depends on flutter_localization from SDK which doesn't exist (could not find package flutter_localization in the Flutter SDK), version solving failed.
I have also correctly added the path to both my flutter and dart SDKs in Android Studio.
Here is my pubspec.yaml file:
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: '>=2.18.2 <3.0.0'
dependencies:
flutter:
sdk: flutter
intl: ^0.17.0-nullsafety.2
cupertino_icons: ^1.0.2
sqflite: any
shared_preferences: ^2.0.15
path_provider: any
flutter_localization:
sdk: flutter
flutter_cupertino_localizations: ^1.0.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
I can't access GlobalMaterialLocalizations without flutter_localization and apparently, this is the easiest solution. I have already tried many solutions like checking version compatibilities and updating all dependencies. can you guys help me out?
Thanks in Advance!
Upgrading SDKs, Upgrading Dependencies, reinstalling flutter and Dart, and more
You misspelled the package
Replace
flutter_localization:
sdk: flutter
With
flutter_localizations:
sdk: flutter
Take note on the s on flutter_localizations
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'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 am little bit confused. When I added easy_localization dependency and run flutter pub get then I give following message:
Because easy_localization >=2.1.0+1 <2.3.4-nullsafety depends on flutter_localizations
any from sdk which depends on path 1.8.0-nullsafety.1,
easy_localization >=2.1.0+1 <2.3.4-nullsafety requires path 1.8.0-nullsafety.1.
I switched to Stable channel of Flutter and I have following Dart version:
Flutter 1.22.6
Dart 2.10.5
Here is my fully pubspec file:
name: demo
description: demo
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: 1.0.0
flutter_bloc: 6.1.1
equatable: 1.2.5
easy_localization: 2.3.3+1
dependency_overrides:
intl: 0.16.1
flutter:
uses-material-design: true
assets:
- assets/translations/
I don't understand why I have dependency conflict. Also I tried remove .lock files. Do you have any ideas where is a problem? Thanks.
Its simple, Just remove dependency version like this
image_picker:
intl:
http: ^0.12.2
It will automatic choose version which is needed
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.