Target of URI doesn't exist: 'package:flame/collisions.dart' - flame

This example for collision detection has an import that is not found, do you know why?
It says: Target of URI doesn't exist: 'package:flame/collisions.dart'
pubspec.yaml
flame: 1.0.0

The new collision detection system was not released in 1.0.0, you can depend on 1.1.0-releasecandidate.4 to use it (we'll release 1.1.0 on Friday).

Related

XCode 14 - Minimum deployment target for SPM package

I am actually compiling for macOS 10.12, as stated. I import the Reachability.swift package, that is compatible down to 10.9. No minimum version is indicated within the Package.swift file. However, I get this error while compiling :
Compiling for macOS 10.12, but module 'Reachability' has a minimum
deployment target of macOS 10.13
It happens since I updated to XCode 14, with version 13, there was no problem.
If I specify the minimum version in the Package.swift of Reachability platforms:[.macOS(.v10_10)],, I clean all the caches, I get the same problem.
I could probably upgrade deployment target to 10.13 (same computer compatibility) or simply include the Reachability.swift file in my code, but I would rather that it works...
[EDIT] Note : other packages, like AppCenter, do not have the same problem… which is weird.
[EDIT 2] With the release of XCode 14.1, the problem remains the same.
Do you have any suggestion ?
I can reproduce your problem: Using AppCenter is OK, but the reachability throws an error.
Here is what I found and maybe this is the root cause:
Make Reachability a local SPM, and modify its swift-tool-version settings and platform settings to align with AppCenter.
Then if you click into the .v10_12 MacOSVersion, you will find os versions lower than 10.13 has all been marked as unsupported
If you head to the built files, test it with otool, you will find the built product's minimum supported version matches with the above description:
So even if you specify the minimum support version to 10.12, the build tools will still target 10.13.
If you check LC_MIN_VERSION_MACOSX on AppCenter. It is also targeting 10.13 instead of 10.12 in its package.swift file.
But why Xcode accepts AppCenter and raise an error for Reachability?
Check the build log below. You will find it in the emitting module stage, the build system is using swift-frontend to embed those 3rd party dependencies. So I guess since the AppCenter is written in objective C.
The checking minimum os version behavior of swift-frontend is different between OC Dependency "AppCenter" and Swift Dependency "Reachability."

Why is riverpod failing even to initialize in project? Method not found: 'Error.throwWithStackTrace'

So i am trying to get started with riverpod and creating a new flutter project with the "click and counter" default sample.
As soon as I add on the pubspec
flutter_hooks: ^0.18.0
hooks_riverpod: ^2.0.0
And
import 'package:hooks_riverpod/hooks_riverpod.dart';
I get this error on the debug console and can't figure it out what is the problem
: Error: Method not found: 'Error.throwWithStackTrace'.
../…/framework/provider_base.dart:904
Error.throwWithStackTrace(error, chain);
^^^^^^^^^^^^^^^^^^^
: Error: A non-null value must be returned since the return type 'Never' doesn't allow null.
../…/framework/provider_base.dart:898
Never _rethrowProviderError(Object error, StackTrace stackTrace) {
^
Error.throwWithStackTrace was added in Dart 2.16 (Flutter version 2.10 from Feb 8, 2022).
https://api.flutter.dev/flutter/dart-core/Error/throwWithStackTrace.html
(Check the #Since annotation.)
If your Flutter/Dart version is below that, you'll get the error you saw.
Two options that may help are:
Specify an exact version of dependencies (don't use ^ ahead of version)
upgrade Flutter/Dart to at least 2.10/2.16
flutter upgrade
If your problematic package (hooks_riverpod: ^2.0.0 in your case) is listed with ^, it'll use the latest version that doesn't break dependencies.
I'm guessing that when you created a new project and used that same dependency version, upon initial pub get it downloaded a newer version of the package (or a newer version of a dependency that that package uses) into "pub cache" which is relying on the new Error API method.
Your project will store this information in:
<your_project_dir>/dart_tool/package_config.json
The min Dart SDK version listed for the package should normally have changed from 2.12 to 2.16. (update: it's been updated now) This would give us a hint that we need to update our Flutter/Dart if we see our build failing.
In an earlier version of this answer, I noted that the ^ prefix on package dependency versions is supposed to prevent these types of issues, but I'm no longer certain it was meant to cover this situation where the underlying platform needs to be updated (as opposed to a breaking change in the API of the package itself).
Anyways, at first glance, it might make sense to go from 2.0.0 to 3.0.0 for a package version # when it depends on a new core Dart API method that did not exist when 2.0.0 was published.
Notes
The author of riverpod also wrote the new API for Error.throwWithStackTrace so likely the latest version of hooks_riverpod is using the latest API changes. (The version you're listing 2.0.0 is pre-release currently). You could try earlier versions of riverpod in your pubspec.yaml (such as 1.0.3)
for anyone facing " Method not found: 'Error.throwWithStackTrace' " with firebase.
try to add this to your pubspec.yaml
dependency_overrides:
firebase_messaging_platform_interface: 3.1.6
I saw this.
How about trying flutter pub upgrade?
If it is not resolved, then check analyzer version and check which dependency locks that.
As noted in Baker's answer, Error.throwWithStackTrace was recently added in Dart 2.16.
If you're getting an error about Error.throwWithStackTrace not being found for some package, the package author neglected to update their package's minimum Dart SDK version. You should report that to the package maintainer. In the meantime, you should use an earlier version of the problematic package or use a newer version of the Dart SDK.
Try running flutter upgrade
By this it will upgrade your flutter and dart SDK version and hope it resolves your issue
if you are still facing the issues after "flutter upgrade" or you use this line of code in pubspec.yaml
dependency_overrides:
firebase_messaging_platform_interface: 3.1.6
you receive this type of errors
java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class com.sun.tools.javac.util.UnsharedNameTable$NameImpl)
at com.sun.tools.javac.util.Assert.error(Assert.java:133)
at com.sun.tools.javac.code.TypeAnnotations.annotationType(TypeAnnotations.java:231)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.separateAnnotationsKinds(TypeAnnotations.java:294)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitMethodDef(TypeAnnotations.java:1066)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:275)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
so Try to upgrade your gradle version, this line in your build.gradle
classpath 'com.android.tools.build:gradle:4.1.0'
after doing that it may be possible it ask you to change your
gradle-wrapper.properties
distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip
to
distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip
also upgarde this packages
firebase_core: ^1.10.0
firebase_messaging: ^11.1.0

Dart: What is the difference between the "Upgradable" and "Resolvable" columns in the output of "dart pub outdated"?

What is the difference between the "Upgradable" and "Resolvable" columns in the output of "dart pub outdated"?
Here is an example of a package that can be upgraded to the latest. The Upgradable, Resolvable, and Latest all match:
url_launcher *6.0.11 6.0.12 6.0.12 6.0.12
Here is an example of a package that is already at the highest resolvable version, but can't be upgraded to the absolute latest version. Presumably another dependency is restricting the resolvability to the latest.
rxdart *0.26.0 *0.26.0 *0.26.0 0.27.2
Here is an example of a package that can't be upgraded any higher but has a Resolvable version that is higher. What does this mean? How is this different from the middle case above?
provider *5.0.0 *5.0.0 6.0.1 6.0.1
In addition to the other very useful posted thoughts, I have learned the following helpful details:
Upgradable refers to the highest version that your direct pubspec will permit, which considers the sdk version and the individual package version (whether to upgrade to just minor or also major). When Upgradable is limited, it can likely be your sdk version holding things back. In my case I was using sdk 2.12, but some packages require 2.14 now (Sep 2021).
From the docs:
The latest version allowed by your pubspec.yaml file. This is the version that dart pub upgrade resolves to. The value is - if the value in the Current column is -.
Resolvable refers to the highest version that all of the other packages' dependencies will allow, in addition to your direct pubspec constraints. When the Resolvable is limited, there is usually one package holding everything back, or a major version holding everything back.
From the docs:
The latest version that can be resolved, when combined with all other dependencies. This version corresponds to what dart pub upgrade gives you if all version constraints in pubspec.yaml are unbounded. A value of - means that the package won’t be needed.
Upgradable means an upgradeable version. Generally, minor version updates can be upgraded directly without modification.
Resolvable can use the version, generally a major version update (the 0.x version may have destructive changes, same as major version), may have incompatible interfaces to the previous version, if you update this version, you may need to change some code
Latest The latest version. If it is inconsistent with the Resolvable version, means the SDK version required by the latest version is inconsistent with the current project
The main difference is that Resolvable mains the version you need to reach to resolve outdated issues in your project and Upgradable mains the version you can update of that package.
To resolve it you must find packages you can update and continue updating until you can update the main package.
You can see it in this link about those concepts: Dart pub outdated

What is the caret sign (^) before the dependency version number in Flutter's pubspec.yaml?

In the pubspec.yaml file of my Flutter project there is a caret (^) before the version number of some of the dependencies.
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
english_words: ^3.1.5
What is its purpose? What does it mean?
Notes
I looked in the yaml documentation but I didn't see anything that made sense.
Related: what does Caret sign do in Dart (but it isn't an XOR operator here)
Related: In Flutter, Dependencies must specify version number? (an answer pointed me in the right direction but the question is asking something different)
The caret sign (^) is used for pub dependencies in Dart to indicate a range of version numbers are allowed. Specifically, any version from the specified version up to (but not including) the next non-breaking version is ok.
So ^3.1.5 is the same as '>=3.1.5 <4.0.0'
And ^1.2.3 would be the same as '>=1.2.3 <2.0.0'
It's shorthand for the longer form.
The ^ is saying, I want to automatically use the most up-to-date package from Pub as long as that update won't break anything in my app.
Notes
The concept of Semantic Versioning is important here. Read the article at the link if you are not familiar with it.
Version constraints documentation
Caret syntax documentation
Clarification for versions less than 1.0.0
Originally I had thought that
^0.1.2 is the same as '>=0.1.2 <1.0.0' (wrong!)
However, that is an incorrect understanding of Semantic Versioning. When the major version number is 0 (as in the 0 of 0.1.2), the meaning is that the API is unstable and even minor version number changes (as in the 1 of 0.1.2) can indicate a breaking change.
The Semantic Versioning article states:
Major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable.
and also
How should I deal with revisions in the 0.y.z initial development
phase?
The simplest thing to do is start your initial development release at
0.1.0 and then increment the minor version for each subsequent release.
Thus, the following is the corrected form:
^0.1.2 is the same as '>=0.1.2 <0.2.0'
Thank you to Günter Zöchbauer for pointing out my error.
See also
How do Dart Package Versions work & how should I version my Flutter Plugins?
The caret sign ^ means the specified version and all newer versions that don't introduce breaking changes relative to the specified version.
Dart follows Semantic Versioning and suggests that to be used for package maintainers as well.
Semantic Versioning defines that
For versions >= 1.0.0, the major version needs to be incremented for breaking changes.
For versions < 1.0.0, the minor version needs to be incremented for breaking changes.
Example:
^2.4.3 means >= 2.4.3 < 3.0.0
^0.17.19 means >= 0.17.19 <0.18.0
It means that any new versions of a dependency that does not contain breaking changes will be accepted.
Dart language follows semantic versioning and uses it for package maintainers.
In layman's terms ^1.8.1 means >= 1.8.1 < 2.0.0

How to publish nuget package with the same version?

I have release version: 1.90. Is it possible to keep this version when I was doing patch updates for my library?
Currently when I am trying to publish with the version 1.90 it shows me the error: "Unable to process request. 'A package with id "TrakopolisAPI" and version '1.90 already exists and cannot be modified.''"
Change the minor version. Unless you can delete the old package i don't think you can publish with the exact same version number