How to scroll to a position in Flutter ListView?

Flutter ListView is very easy to use, and very versatile. As an Android developer used to creating Adapters for my RecyclerViews, I appreciate the simplicity of Flutter. However, one often used functionality is lacking, and it is smoothScrollToPosition(int position).

There is currently an open github issue  requesting this very feature.

In the meanwhile, for lists where all items have the same height, there is a trick you can use.
Continue reading “How to scroll to a position in Flutter ListView?”

How to parse JSON in Dart / Flutter

JSON is a cornerstone in most Android apps, but how do you parse JSON in Dart and Flutter?

As mentioned in my “4 tips to boost your software development career” post, I’ve been experimenting with Flutter recently. Dart, the language used by Flutter, comes with a good library to parse JSON (dart:convert) but after having used gson for years in my Android apps, I had to relearn how to parse JSON.

If you Google gson for Dart , you will also find a library called dson. However, for this code tutorial, I’m focusing on using dart:convert.

To follow the code tutorial, create a new app as follows.

If you’re unsure how to set up a Flutter app, check out Getting started with Flutter official tutorial.

Continue reading “How to parse JSON in Dart / Flutter”