This week in Flutter #13
Tags: flutter, dart, news
Published: 2021-07-24 13:46:13

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** 🎉.

<figure class="kg-card kg-embed-card"><blockquote class="twitter-tweet"><p lang="en" dir="ltr">We're happy to welcome <a href="https://twitter.com/_mvolpato?ref_src=twsrc%5Etfw">@_mvolpato</a><br>as the new Tech Editor on our Flutter team!</p>— raywenderlich.com (@rwenderlich) <a href="https://twitter.com/rwenderlich/status/1418479374567841794?ref_src=twsrc%5Etfw">July 23, 2021</a></blockquote><script async="" src="https://platform.twitter.com/widgets.js" charset="utf-8" type="38c0ae39ed609d91895c2f2f-text/javascript"></script></figure>

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

<small>- Michele Volpato</small>

## 🧑‍💻 Development

### [Better Bloc and Cubit Unit Testing](<https://dev.to/danielcardonarojas/better-bloc-and-cubit-testing-98p>)

Did you ever have problems creating **unit tests** while using the [BLoC](<https://medium.com/flutter-community/flutter-bloc-with-streams-6ed8d0a63bb8>) pattern?<br>

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](<https://github.com/DanielCardonaRojas>) 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](<https://dev.to/carlomigueldy/generating-fake-data-in-flutter-using-the-factory-pattern-for-unit-testing-3i8k>)

... and after you learn how to write tests, you might need to create **fake data** for such tests. [Carlo Miguel Dy](<https://twitter.com/CarloMiguelDy>) shows you how in this article.

---

### [Unit testing DateTime.now() with the help of Dart extensions](<https://remelehane.dev/posts/unit-testing-dattimenow-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](<https://remelehane.dev>) 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](<https://bartvwezel.nl/uncategorized/cat-and-mice-part-4-implementing-the-ai/>)

[Bart van Wezel](<https://twitter.com/bartvwezel>) 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](<https://www.youtube.com/watch?v=sXBJZD0fBa4>)

Watch [Todd Kerpelman](<https://twitter.com/ToddKerpelman>) 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](<https://www.raywenderlich.com/24346128-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](<https://twitter.com/vguzzi_dev>).

---

## 🧑‍🎨 Design

### [Flutter for Single-Page Scrollable Websites with Navigator 2.0](<https://medium.com/flutter-community/flutter-for-single-page-scrollable-websites-with-navigator-2-0-part-1-introduction-c219b471bbec>)

In this series of articles, [Cagatay Ulusoy](<https://twitter.com/ulusoyapps>) 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.

---

[...]

[Read the rest on ishouldgotosleep.com](https://ishouldgotosleep.com/this-week-in-flutter-13/)