I have a flutter app that I am trying to build through bitrise.
I keep getting a tonne of errors along the lines of
Error: The 'super-parameters' language feature is disabled for this library.
Try removing the package language version or setting the language version to 2.17 or higher.
super.key
and it is blocking me from analyzing and building the app.
Now the issue is, I am using flutter install with upgrade set to true , and have sdk target in my pubspec.yaml as
Environment:
sdk: ">=2.17.6 <3.0.0"
I disabled the caching steps, and tried to create a new deployment pipeline, to no avail.
In your workflow, add Flutter Install, Then set your desired flutter version on Input Variables sections's Flutter SDK git repository version field. e.g. 2.8.0.
Related
I have an old project that is not nullsafety. I'm currently using open_file: ^3.0.3 package for opening files. But with recent google play policy, REQUEST_INSTALL_PACKAGES is not allowed. Is there any flutter package that has the same function but still has a none nullsafety version? Or a native code that will do the same function? I've seen
open_file_plus
open_filex
open_file_safe
but they don't have a non nullsafety version.
I created a new Flutter project and did a
flutter pub get
There are no errors from the framework except the one from AppLocalizations class.
Target of URI doesn't exist: 'package:flutter_gen/gen_l10n/app_localizations.dart'.
Another error (obviously because of the same package)
NOTE:
I have already tried:
Restarting IDE + Invalidate Caches and Restart
flutter pub add flutter_gen
Restarting Dart Analysis Server
Updating packages
I'm using: Flutter 2.6.0-11.0.pre • channel dev
You can expect all sorts of surprises when switching between channels (and specifically when using Dev or Master channel).
If switching to stable or beta channel (flutter channel stable and flutter upgrade) due to some reasons is not an option I'd suggest upgrading flutter (newer version might have a fix) cleaning the proj OR recreatign platform projects:
flutter upgrade
flutter clean
flutter create .
Besides, I'd stick to beta channel rather than dev/master - it's typically better tested and has fewer issues.
Note that in 2022 dev channel is no longer available leaving master as the most recent and least tested branch.
flutter_gen/gen_l10n dir is auto generated by flutter and located in .dart_tool. (It's not related to the package named flutter_gen in pub.dev).
Try this,
flutter clean
then,
flutter pub get
If the flutter_gen/gen_l10n dir is not available yet follow the below steps.
Step 0: Make sure you have these in pubspec.yaml,
flutter:
generate: true
and
dependencies:
flutter_localizations:
sdk: flutter
Step 1: Comment everything related to AppLocalization if you can't run the app with them. (Imports & Usage)
Step 2: Now run the app.
Now the flutter_gen/gen_l10n folder will be generated.
Finally: Un-comment everything related to AppLocalization.
Every time you make changes to .arb files you will need to flutter get / run / hot reload / hot restart the app to update generated localization files.
Change these lines in pubspec.yaml file
From
flutter:
uses-material-design: true
To
flutter:
uses-material-design: true
# Enable generation of localized Strings from arb files.
generate: true
Then run:
flutter clean
flutter pub get
flutter run
I have a project that is developed with Flutter v1.22.6 and was working great, after updating the flutter to v2.0.0 and reading the documentation, I've found out I can use dart migrate --apply-changes to fix issues that are related to flutter upgrade, By running the command I get dozens of errors and the error ends with:
The migration tool didn't start, due to analysis errors.
The following steps might fix your problem:
1. Set the lower SDK constraint (in pubspec.yaml) to a version before 2.12.
2. Run `dart pub get`.
3. Try running `dart migrate` again.
What is the simplest way to migrate the current project to the v2?
The problem is that you have already migrated to a newer version of dart.
You can't migrate your projects from the new version, there is literally nothing to migrate to.
If you want to migrate your older projects (which are without null safety) to a new version, your dart version must be older than 2.12.0 version.
In this case, consider changing the version in your pubspec.yaml file.
environment:
sdk: '>=2.11.0 <3.0.0'
Then run the command in your terminal
> dart migrate --apply-changes
make sure you have following step by step migrate dart 2
and base on your error notification try to set in pubspec.yaml
environment:
# Works in Dart 2 only.
sdk: '>=2.0.0 <3.0.0'
Using Flutter, I am trying to update my dart dependency 2.6.0 but I get an error
Because *project_name* requires SDK version >=2.6.0 <3.0.0, version solving failed.
pub get failed (1)
exit code 1
I want to use the new features that dart offers, such as Extension Methods. How could I go about upgrading my dependency? I have installed the newest stable version of dart on my computer, but regardless I still get that error.
A couple of things that might help:
From this issue, you can try ensuring that you've updated enviroment in your pubspec.yaml file like so:
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
Another thing that might help is just double checking the steps in this post or on the dart installation page to ensure that you've updated to the latest version correctly.
I am playing around with non-nullable types and added this to my analysis_options.yaml:
analyzer:
enable-experiment:
- non-nullable
I have a code-generator that is utilising the nullability extension. Visual Code is fine with my code.
Now, I try to run:
flutter packages pub run build_runner watch
I get this error message:
[SEVERE] Failed to snapshot build script .dart_tool/build/entrypoint/build.dart.
This is likely caused by a misconfigured builder definition.
[SEVERE] xyz.dart:95:7: Error: This requires the 'non-nullable' experiment to be enabled.Try enabling this experiment by adding it to the command line when compiling and running.
How can I pass --enable-experiment:non-nullable to flutter packages pub run?
The same happens if I run:
flutter build ios
I get the error message:
lib/main.dart:61:26: Error: This requires the 'non-nullable' experiment to be enabled.
Try enabling this experiment by adding it to the command line when compiling and running.
So, same question: How can I pass --enable-experiment:non-nullable to flutter build?
This problem was occured for me after upgrading the Flutter.
I solved it by cleaning and upgrading the project dependencies again.
Run the below commands in the root directory of your project:
flutter clean
flutter packages pub upgrade
flutter pub run build_runner build
Also as others said, please make sure your sdk version in the pubspec.yaml is compatible with your flutter sdk version.
For null safety to work,
environment:
sdk: ">=2.12.0 <3.0.0"
should be this version at least.
then run flutter clean
and flutter pub get it will work.
Try
flutter clean
This is worked for me!
Depending on what you're doing, sometimes it's as simple as changing the environment in your pubspec.yaml file to update the lower end, ie change a lower end like
environment:
sdk: ">=2.0.0 <3.0.0"
to
environment:
sdk: ">=2.6.0 <3.0.0"
or
environment:
sdk: ">=2.7.0 <3.0.0"
This has worked for the various things that cause this error (using spread syntax in latest version of flutter and dart will also cause this), but I don't need the older environments.
A simple fix for me was to ensure that the analysis_options.yaml is in
the root folder. In my case, it was in the lib folder and none of the
experimental features worked until I moved the file to the same folder
as pubspec.yaml. Other things that can happen include updates that
make the experimental feature no longer required so updating to the
latest version on the flutter master channel may be useful in addition
to verifying the file location. Haven't been able to get the command line
running with this option, however.
Dart Reference
Example of Analysis Options File