-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The 'variance' language feature is disabled for this library. for Dart 3.5.4 on Flutter Web #57112
Comments
Summary: Upgrading Flutter from 3.4.3 to 3.5.4 caused build errors on web. The |
@tolotrasamuel, perhaps it would be useful for you to emulate invariance rather than trying to use I think we already touched upon this in a different thread, but the point is that the An example is given here: dart-lang/language#524 (comment). If you are able to use the emulation then you will have the full semantics at run-time and the full static checking at compile-time. The other side of the coin is that you can't use contravariance, it only works for invariance. |
In our previous discussion, we discussed that there are two ways to simulate the behavior of The first approach involves wrapping the field in a private method. However, this workaround has its drawbacks. It requires wrapping multiple callback fields in private methods, which can become cumbersome and lead to code that is difficult to maintain and read when there are many such methods. The second approach uses For these reasons, I opted to use the |
OK! However, it is actually the |
A couple questions that might help debug the issue of the
I tried reproducing this at Flutter head and the |
Experiment flags only works for code that is on the most recent language version, which is (theoretically) the language version the experiment is written to work with. If your pubspec has an |
Without additional information we're not able to resolve this issue. Feel free to add more info or respond to any questions above and we can reopen the case. Thanks for your contribution! |
Thanks @lrhn that was the issue. Moving forward, I suggest adding this statement in the Experimental Flag Web because I would have never guessed.
Also, I worked on a Flutter package, and it is using a local package that uses the experiemental flag. Both the main project and the package needed to increase the sdk version restriction to the latest |
flutter build web --web-renderer html --csp --enable-experiment=variance
In the previous version I tested,
3.4.3
this command above works fine.3.22.2 │ stable │ 3.22.2 │ 3.4.3 │ Jun 6, 2024 │ │ ● │
I upgraded to
3.5.4
and I got the following errors:3.24.5 │ stable │ 3.24.5 │ 3.5.4 │ Nov 14, 2024 │ │
It is worth nothing that this does not occur on Android and iOS build, but I faced it on Web.
The text was updated successfully, but these errors were encountered: