Home > Software design >  New version of flutter giving bunch of errors in my previous code
New version of flutter giving bunch of errors in my previous code

Time:01-04

I have set my development environment on another system with everything new. Latest android studio version, flutter, and everything.

Now I am trying to run my previous code but the whole code is full of errors. The code was working perfectly fine on my previous version of flutter. I didn't get the issue with this new version.

Here is the screenshot of my code:

Image1

Anyone please help me to solve this issue. This is my whole project with some other code as well and there are nearly 70 files of code. I would be thankful if anyone can help me with this issue. Thanks

CodePudding user response:

This is because Dart introduced null safety. You have to make your code null safe by using various annotations and operators. You can learn more about them here -

https://dart.dev/null-safety

https://dart.dev/codelabs/null-safety

https://dart.dev/null-safety/understanding-null-safety

CodePudding user response:

Well, you semed to have had a really, really old version of Flutter (and Dart) before.

One way to fix those errors is to read and understand the guide to null safety and modify your project. It will be better after you do it, null safety is an amazing feature.

If you don't have the time to do that right now, you should be able to just constrain your SDK to an earlier version. Quite frankly I'm surprised that you got null safety out of the box because your project should have had constraints. If you set the minimum SDK version to something smaller than 2.12 you should be running without that feature. But please note that sooner or later you will need to enable it, you cannot stay on an obsolete version. So maybe it's time to do that now.

  •  Tags:  
  • Related