i am getting error on The lower bound of "sdk: '>=2.11.0 <3.0.0'" must be 2.12.0' or higher to enable null safety. and red lines on flat button,

huangapple go评论115阅读模式
英文:

i am getting error on The lower bound of "sdk: '>=2.11.0 <3.0.0'" must be 2.12.0' or higher to enable null safety. and red lines on flat button,

问题

Today, I got a job after struggling so much, Now they asked me to clone a project from master file and run the project, from past two days i ma trying hard to run the project but i am getting errors like in whole project i am getting error on snackbarshow, flatbutton, raisedbutton, and zoomopion, they are on red lines, and also i am getting error on dependencies like Resolving dependencies...

The lower bound of "sdk: '>=2.11.0 <3.0.0'" must be 2.12.0' or higher to enable null safety.

The current Dart SDK (3.0.3) only supports null safety.

i have tried almost every solution on google like changing sdk version in pubspecyml file and also upgrade my flutter too, here is my flutter info: i am using android studio, Flutter is already up to date on channel stable
Flutter 3.10.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 682aa387cf (2 days ago) • 2023-06-05 18:04:56 -0500
Engine • revision 2a3401c9bb
Tools • Dart 3.0.3 • DevTools 2.23.1

英文:

Today, I got a job after struggling so much, Now they asked me to clone a project from master file and run the project, from past two days i ma trying hard to run the project but i am getting errors like in whole project i am getting error on snackbarshow, flatbutton, raisedbutton, and zoomopion, they are on red lines, and also i am getting error on dependencies like Resolving dependencies...
The lower bound of "sdk: '>=2.11.0 <3.0.0'" must be 2.12.0'
or higher to enable null safety.
enter image description here

The current Dart SDK (3.0.3) only supports null safety.

i have tried almos every solution on google like changing sdk version in pubspecyml file and also upgrade my flutter too, here is my flutter info: i am using andriod studio, Flutter is already up to date on channel stable
Flutter 3.10.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 682aa387cf (2 days ago) • 2023-06-05 18:04:56 -0500
Engine • revision 2a3401c9bb
Tools • Dart 3.0.3 • DevTools 2.23.1

答案1

得分: 1

似乎这个项目是用非常旧版本的Flutter制作的,还没有使用空安全。如果我没记错的话,空安全是在Flutter 2.0.0版本中引入的,而在那之前的版本是1.22.6。如果你不想迁移项目以使其与最新的Flutter兼容,你可以尝试在Flutter 1.22.6下运行它。不过,如何做到这一点并不是很直接。你可以尝试打开命令提示符并进入Flutter SDK所在的文件夹,然后输入以下命令:

git checkout 1.22.6

之后在你的项目中运行以下命令:

flutter doctor

看看是否已经切换到了正确的Flutter版本。

这并不能保证一定会成功,但是值得一试,尽管我认为成功的机会很小。如果不起作用,恐怕你需要重构项目以使其与最新版本的Flutter兼容。如果你想撤销 git checkout 1.22.6 命令所做的更改,只需在项目中执行以下命令:

flutter channel stable

flutter upgrade

英文:

It seems this project was made with a very old version of flutter. Before null-safety. If I'm not mistaken they introduced that in version 2.0.0 of flutter and the version before that is 1.22.6. If you don't want to migrate your project to make the project compatible with the latest flutter you can try to run it with flutter 1.22.6. Unfortunately it's not very straightforward how to do that. What you can try to do is open a command prompt and go the folder where your flutter sdk is located and write

git checkout 1.22.6

After that try a

flutter doctor

in your project, and see if it changed it to the right flutter version.

This is not guaranteed to work, but it's worth a try, although I think there's only a small chance that this works. If it doesn't work I'm afraid you will need to refactor the project to make it work with the latest flutter version. If you want to revert the change that git checkout 1.22.6 did simply do

flutter channel stable

and

flutter upgrade

from your project.

答案2

得分: 0

更好的做法是更改 flutter_zoom_sdk,因为它已过时并引发错误。尝试使用 => zoom: ^1.0.4,或者通过方法通道为每个平台添加 通用 Zoom SDK。还建议将所有包更新为 Dart 3 兼容版本,以避免未来出现问题。还可以使用 dart fix --dry-run 来查看建议的更改,然后使用 dart fix --apply 来应用它们。

英文:

Its Better to change the flutter_zoom_sdk as its out of date and causing errors.
try using=> zoom: ^1.0.4 or add the general zoom SDK for each platform using method channel. Its also recommended to update all the packages to Dart 3 compatible versions for avoiding future issues. Also Use dart fix --dry-run to see suggested changes and dart fix --apply to apply them.

huangapple
  • 本文由 发表于 2023年6月8日 13:35:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76428872.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定