Upgrade My Projects to Flutter 2.0 Experience And It Suprises Me

Hi all, this post I'm gonna share what I encounter when upgrading the project to flutter. Especially this app Food Today. That's been around 1 years in App Store and Play Store. The app helps people to capture moment with their daily foods so they can control it as food diary. Other than that there's food holiday everyday that will inspire you to eat what foods for today. Still a lot of features that you can get. Just try it.

I have an issue on iOS where I need to update my pod file to make platform :ios, '11.0'. Before It's 9.0, I think now 9.0 is deprecated and we can't use it anymore for the next updated plugin. Like I used a lot firebase feature. And so thare are coding adjusment that will break your code that you need to read the their docs. But usually there's error message in console about proper way to solve it.

Now like snackbar from flutter need to be changed according to the new one, https://flutter.dev/docs/release/breaking-changes/scaffold-messenger. Fortunely there's a doc from flutter to update it. For my self it's not hard to update the changes, but more like time consuming to replace it one by one. But for better app we need to transform it. So it's no problem in the end. We use it free lol.


Next, I got so many error dependecies like these, it's quite painful for me to check it one by one. The fix is to update the plugin version to the latest one. Every thing that's breaking need to be updated if not your app will never run in this new flutter. For me, it takes almost two days to update and check it if it's work or not. And sadly there's a library that i need to change because it's not updated yet. The plugin is for google admob, before I don't use the official one because it doesn't support banner widget and now it supports it. So I need to change it as well, quite painful. But hope the old issue doesn't happen again that's crash when opening the page that has admob.

Running "flutter pub get" in food_today_flutter...
Because wc_flutter_share 0.2.2 depends on path_provider ^1.6.8 and no versions of wc_flutter_share match >0.2.2 <0.3.0, wc_flutter_share ^0.2.2 requires path_provider ^1.6.8.
So, because food_today depends on both path_provider ^2.0.2 and wc_flutter_share ^0.2.2, version solving failed.

After that I need to solve many errors regarding changing plugin has made. Not only that there anre many class that's deprecated like FlatButton, RaiseButton, etc. The migration docs for button is in here. You need to adapt new style for the button that I think it looks good. 



The good thing is I can update my plugin to latest like camera plugin made by flutter. It gets new feature like flash and focus that I can use in my apps. And I hope my app will be better and doesn't have crash in prod anymore.

Another thing the apple_sign_in package that's not updated from the dev. In github it says the package is no longer updated again. So it's shock me first how can I update to null-safety feature if one of the plugin is not null-safely. Luckily after I read discussion in github there's someone that made it null-safety with different plugin name. It's called the_apple_sign_in package you can search in google. Or I share it here https://pub.dev/packages/the_apple_sign_in.

One thing more is you need to check every plugins is null-safety to use the null-safety feature in your code. You need to use this one to check it dart pub outdated --mode=null-safety. The full guideline in here https://dart.dev/null-safety/migration-guide. 

There's another plugin called flushbar that I used to show toast message like android where the developer doesn't update again the plugin in github. So luckily there's someone who make it null safety so I can still use the plugin. The plugin called another_flushbar you can see it here https://pub.dev/packages/another_flushbar.

If you need to use null-safety in your code. you need to update your sdk version to sdk: ">=2.12.0 <3.0.0" as well. I got this info from this stackoverflow answer and it works https://stackoverflow.com/a/65117431. You'll get suprised because there are lot of errors will happen in your code that you need to solve it again.

I think that's all my experience when upgrading my project to flutter 2 or null-safety. As developer we need to adapt in new technology or new update from anything. Make it like hobby to spend and share it with others so it can benefit to others as well.

And sorry if my grammar is not good, I still learn it but I hope you get my point. Thanks for visiting my simple blog by Ungapps. It's been a many years to write this blog. And I hope I can continue it again and again.

Popular posts from this blog

Missing system image Android Studio solution

How to have ConstraintLayout inside ScrollView and ScrollView inside ConstraintLayout Android

Fixing Keyboard Hide When Reload UITableview iOS swift 5