Andrea Bizzotto 🇺🇦 Profile picture
Flutter GDE ❖ I share tips about Dart & Flutter app development. Get my latest Flutter tips, articles, and resources → https://t.co/Hp3oN9C7q8
Mar 20, 2023 12 tweets 4 min read
Can GPT-4 and GPT-3.5 play Wordle? 🤔

I decided to find out! Here's what I discovered:

✅ GPT-4 understands the game and can improve on each move
❌ GPT-3.5 doesn't quite get it 😅

Want to know all the details (prompt & answers)? Then read on! 🧵 GPT-4 completed Wordle in 4 moves: - apple (XXXXO) - ember ( First of all, I've used the same prompt for both models.

I tried to be very explicit about the game rules and provided an example.

Here's what it looks like. 👇 I need your help playing Wordle. Your job is to guess an exi
Sep 30, 2022 15 tweets 3 min read
I know that many people out there are looking for their first tech job (Flutter or otherwise) and times are tough.

Having hired talent twice in the last year, I received many applications but very few good ones.

So here's some advice from a "hiring manager" perspective.

🧵 If you knew you had FIVE seconds to make a good impression, what would you do?

This is not a hypothetical question.

If a hiring manager has 50 applications sitting in the inbox, how would they quickly tell the good from the bad ones?

In other words, how do you stand out?
Sep 29, 2022 14 tweets 7 min read
If your users speak another language, you’ll need to localize your Flutter app 🗺

Here’s how to setup Flutter app localizations in just 5 minutes, using code generation.

Also covered: template vs non-template files and synthetic vs non-synthetic package. 👀

🧵 Image 1️⃣ As a first step, we need to add the required packages to the pubspec.yaml file. Image
Jul 25, 2022 7 tweets 3 min read
What's the difference between errors and exceptions in Flutter?

→ Errors are programmer mistakes. They are fatal and we should not try to recover from them
→ Exceptions are failure conditions that are out of our control. We should handle them and recover gracefully

Thread 🧵 Image Errors are fatal and when they happen the program *cannot* recover normally.

→ we want to discover (and fix) them as early as possible in the development process
→ we should track them in production using a crash reporting solution, so that we can measure impact and severity
Jul 11, 2022 12 tweets 3 min read
In the last few months, I've been sharing many useful Flutter tips & tricks. 💙

Here are the top 10! 👇🧵 Here's a list of my top 10 Flutter tips & tricks. 1) Rules to follow for good app architecture

Jun 9, 2022 4 tweets 2 min read
Sometimes we need to write business logic inside classes that have multiple dependencies.

To do this, we can pass the dependencies as constructor arguments.

A much simpler solution is to pass `ref.read` as an argument.

Here's a thread with all the details. 🧵 Reader is just a function we can use to read a provider's value, *just once*.

And once we get the underlying value (a repository in this case), we can call methods on it.

Note: when we want to access a provider inside a widget callback, we do exactly the same thing.
Apr 25, 2022 7 tweets 4 min read
When using Riverpod, what is the difference between ref.watch(), ref.read() and ref.listen()?

It really boils down to this. 👇

For more details, here's a thread. 🧵 Image For example, suppose you have a logout button which behaves like this:

- When pressed, call a method to sign out
- While sign out is in progress, disable the button
- If an error occurs, show a SnackBar

As a starting point, we can create our button as a ConsumerWidget: Image
Apr 4, 2022 9 tweets 4 min read
How do you generate (and make the most of) test coverage in Flutter?

This is very easy to do.

And there are VSCode extensions that help you integrate coverage data with your testing workflow.

Thread. 🧵 Image First of all, you need a Flutter project with tests. I'm sure you write them, right? 😉

Then, you can run these three commands to generate the LCOV data and open a report on your browser.

Tip: make sure the "coverage" folder is added to ".gitignore". Image
Mar 22, 2022 13 tweets 4 min read
What's the best project structure for medium/large Flutter apps?

Most likely, there's no "right" answer that works for all projects.

So let's explore two popular approaches known as "feature-first" and "layer-first" and learn about their differences.

Thread. 🧵 Image First of all, it's best to consider project structure in relation to app architecture.

For reference, let's consider this high-level architecture made of four layers:

‣ presentation
‣ application (optional)
‣ domain
‣ data Image
Mar 16, 2022 14 tweets 5 min read
What are some popular architectures that are suitable for Flutter App Development (and which one to choose)?

It boils down to what level of complexity you need to handle. 👇

Thread. 🧵 Image (1/2) Model–view–controller (MVC) is a software design pattern made of 3 types of components:

- Model: directly manages the data, logic, and rules of the application
- View: UI components (widgets)
- Controller: Accepts input and converts it to commands for the model or view Image
Mar 14, 2022 8 tweets 2 min read
What are some rules to follow for good app architecture in Flutter?

Thread. 🧵 RULE: Avoid singletons

If you want your code to be testable, there are various alternatives to singletons:

- constructor arguments (doesn't scale well with deep widget hierarchies)
- InheritedWidget or Provider
- Service locators (e.g. get_it)
Mar 9, 2022 10 tweets 4 min read
When using GoRouter for declarative navigation, you'll often have to choose between:

- GOING to a route
- PUSHING a route

What is the difference between the two?

A thread. 🧵 Image To start off, let's consider a simple route hierarchy made of one top route with two sub-routes. Image
Mar 1, 2022 6 tweets 3 min read
WidgetsBindingObserver is very handy for listening to changes to:

- routing events
- device orientation
- platform settings (text scale factor, brightness, locale, etc.)
- app lifecycle events

Here's how to use it to hide sensitive info when the app goes to the background. 🧵 Image How to set it up?

- add the WidgetsBindingObserver *mixin* to one of your classes (generally a State subclass)
- register the observer inside initState (and dispose it when done) Image
Feb 28, 2022 5 tweets 3 min read
I’ve been watching the events unfolding in #Ukraine with great concern.

And it's clear that many people need humanitarian aid, *right now*.

If you have the means to do so, donate your money (I have).

This thread lists a few non-profits helping people during this crysis. 👇 If you haven't already seen this, here's display of much needed, true leadership from the Ukranian president:

Feb 23, 2022 10 tweets 5 min read
What are some VSCode extensions you can use to speed-up your Flutter workflow?

Here's a thread with my favourites! 🧵 When creating model classes, you'll often needs methods such as:

• copyWith()
• toString()
• toJson()
• fromJson()
• toMap()
• fromMap()
• == operator
• hashCode

Use the Dart data class generator to create them all in one go!

Link: marketplace.visualstudio.com/items?itemName…
Feb 10, 2022 14 tweets 4 min read
How do we apply Domain-Driven Design to exception handling?

I've been experimenting with some techniques and would love your feedback about this thread. 🧵

First of all, let's establish some goals: 👇 To define all the domain-specific exceptions, sealed unions come to hand.

Here's how we may generate Auth and Database exception types using Freezed:
Feb 9, 2022 7 tweets 3 min read
Domain-Driven Design helps us write complex software.

At the heart of it lies the *domain model*, which is a conceptual model that incorporates both behavior and data.

Sounds complicated?

Let's explain with an example. 🧵 Suppose we want to build an eCommerce app.

To better understand this domain, we need to figure out:

- the entities we care about and their relationships
- the behaviour (or business logic) for manipulating them

The end result may look like this:
Jan 26, 2022 6 tweets 2 min read
The default way of accessing localized strings inside your widgets is to use the `AppLocalizations` class.

However, using the `!` operator everywhere is not good practice.

And it would be nice to have some more "lightweight" syntax.

A thread. 🧵 Image One issue we have is that `AppLocalizations.of(context)` returns a *nullable* object.

But at runtime this will never be null, as long as we call it inside a *descendant* of MaterialApp (which is always the case).

So what can we do? Image
Jan 21, 2022 12 tweets 4 min read
When building non-trivial apps, following a *structured workflow* can bring great benefits and avoid many pitfalls.

Rather than diving straight into the code, here's a 6 step workflow that you can follow.

Thread. 🧵 1. Design your app (part 1)

Design all the screens that will be in your app.

You can use Sketch, Figma, Adobe XD, or even draw them by hand.

This will help you think about the most logical UI flows before diving into the code.

Here's an example from my website: 👇
Jan 7, 2022 4 tweets 2 min read
"Program to interfaces, not implementations" is a very important concept in software design.

It is used to decouple your code from implementation-specific details.

A good use case for this is when creating repositories that connect to external data sources: Once you have an interface (abstract class), you can *implement* it with a concrete implementation.

You can even create a "fake", which can be very useful in your tests.
Dec 31, 2021 11 tweets 3 min read
Here's a thread about my 2021 in numbers as a content creator making Flutter tutorials and courses. 🧵

Total Revenue: $69,532

Here's a breakdown by month. 👇 Here's a pie chart about revenue by income stream.

80% of total revenue came from sales on Udemy and Teachable.