3 min read

This week in Flutter #13

Unit testing in Flutter and connecting to Firebase Realtime Database are the main subjects this week.

We have many resources about testing and some about Firebase Realtime Database. It is almost like content creators agree on the subject of the content they publish.

I give a lot of space to other developers in this newsletter so I think I deserve to share some of my achievements: this week I joined the Flutter team at raywenderlich.com as a tech editor 🎉.

The content available at raywenderlich.com is always of high quality, so I am honored to be part of the team.

- Michele Volpato

🧑‍💻 Development

Better Bloc and Cubit Unit Testing

Did you ever have problems creating unit tests while using the BLoC pattern?I surely did. This was one of the reasons why I am not using it anymore in the new apps I work on. Daniel Cardona Rojas comes to the rescue with this article, explaining his solution to the problem…

Generating Fake Data in Flutter using the Factory Pattern for Unit Testing

… and after you learn how to write tests, you might need to create fake data for such tests. Carlo Miguel Dy shows you how in this article.

Unit testing DateTime.now() with the help of Dart extensions

Using DateTime.now() in your code makes unit testing more difficult. You do not know how much time passed between the call to DateTime.now() and the moment you test its value, so you cannot compare timestamps. Reme Le Hane proposes a solution based on extending DateTime. I wonder if you can separate the two static methods into two different extensions, so that you can declare the setter only for testing, to avoid accidentally use it in your production code.

Another solution is to have a World service that you can inject into other classes. This service will provide values like DateTime.now() in production, or the real value for some sensors, or GPS location. While during testing it can be fully mocked.

Cat and Mice – Part 4: Implementing the AI

Bart van Wezel is continuing the implementation of his game with some artificial intelligence. He also implements some UI. The game is taking shape.

🗄 Backend

The Firebase Realtime Database and Flutter - Firecasts

Watch Todd Kerpelman in a new video about using Realtime Database with Flutter, finally clarifying (to me) when to use Realtime Database and when to use Firestore.

Firebase Realtime Database Tutorial for Flutter

Two good resources about Realtime Database and Flutter in the same week. Is this a coincidence? Yes, it is. If you prefer to read rather than watch the Firebase video, you can follow this tutorial by Vincenzo Guzzi.

🧑‍🎨 Design

Flutter for Single-Page Scrollable Websites with Navigator 2.0

In this series of articles, Cagatay Ulusoy shows different ways to create a single-page website using Flutter. You might think this is an easy topic, but a lot is going on and there are some choices you will need to make even before starting to code.

🛠 Tools

Flutter Code Generation: Getting Started

We all used code generators in Flutter. Maybe to create some classes for a database we use in the app. But do we understand them?In this article, Aachman Garg dives into what they are and how they work in Flutter.

🤷‍♂️ Others

Finding the importance of proper null safety migration (The Boring Flutter Development Show, Ep. 50)

At the end of the previous The Boring Flutter Development Show, Filip and Fitz encountered a bug. In this episode, they will find out what is happening.

Capturing a Flutter widget as an image using RepaintBoundary

This is an interesting article. What if you want to create an image from a widget in your app? For instance, you want the user to be able to share a piece of art created by them. Jordan Holland answers your questions.

That’s it for this week.

If you want to comment on any of this week’s entries, you can do it in the comment section below.

Have a bug-free week,

- Michele Volpato

Subscribe to this newsletter

Receive an email every week with curated content about Dart and Flutter.

You will also receive a list of resources to learn Flutter.

    We won't send you spam. Unsubscribe at any time.