Skip to main content

10 posts tagged with "blog"

View All Tags

The Hidden Cost of Async Misuse in Flutter (And How to Fix It)

· 20 min read
Majid Hajian
Developer Advocate

Cover

I still remember the week I hunted a mysterious Flutter performance issue which had no crashes or error logs; just a sluggish app and somehow an increase usage of memory. Guess what? The issue was a missing await here, an unguarded setState() there.

These bugs don’t crash your app or shout errors; they silently cause memory leaks, UI glitches, and race conditions that surface only after extended use. Problem is that when you spot these behaviors or degraded performance, the damage is done.

In this post, I’ll share what I learned about async misuse’s hidden costs in Flutter, with real examples and fixes. We’ll explore common pitfalls (some of which I’ve embarrassingly written myself), see their sneaky production impacts, and how to use tools like DCM to catch them early.

15 Common Mistakes in Flutter and Dart Development (and How to Avoid Them)

· 41 min read
Majid Hajian
Developer Advocate

Cover

As Flutter projects grow, mistakes that didn’t matter early on can start affecting performance, stability, and maintainability. Some are easy to miss. Others are misunderstood or handled inconsistently across teams.

In this article, I am going to focus on mistakes that are common in Flutter and Dart apps, especially in larger codebases or long-running apps which I have often seen in the last 6-7 years of being in the field. They range from memory leaks and rebuild issues to state misuse, testing gaps, and architectural problems. All of them are avoidable. Most can be detected with static analysis such as DCM. Some require deeper architectural decisions.

Let's get started and see which of these issues are familiar to you and which of them you already have done! I bet you can resonate with many of the following issues.

10 Lesser-Known Dart and Flutter Functionalities You Should Start Using

· 44 min read
Majid Hajian
Developer Advocate

Cover

I started writing Dart code in 2019, and since then, I've been learning something new every day. It’s fascinating to see what this framework and language have to offer.

In this article, I want to share some of those hidden gems I’ve discovered—lesser-known functionalities that can simplify your development process and add a unique touch to your apps. Moreover, we will go deeper into the implementation and explore how they are implemented to learn more about the patterns.

Let’s uncover some of these functions and methods together!

Step by Step Guide to Integrate DCM Into A Flutter & Dart Open Source Package: dart_mappable

· 17 min read
Majid Hajian
Developer Advocate

Cover

I recently had the pleasure of collaborating with Kilian, the developer behind several Dart and Flutter open-source packages, including the popular "dart_mappable". "dart_mappable" is a package that simplifies JSON serialization, data classes, and supports powerful features like advanced inheritance and generics.

In this post, I'll walk you through how we integrated DCM into "dart_mappable" and show you how you can select rules, create baseline and start fixing issues quickly.

10 Flutter Widgets Probably Haven’t Heard Of (But Should Be Using!)

· 34 min read
Majid Hajian
Developer Advocate

Cover

It’s been over 6 years since I started developing with Flutter and Dart, and yet I still come across features or widgets that I didn’t know existed. It’s fascinating how a framework you work with daily can still surprise you with its depth and versatility.

In this article, I want to share some of those hidden gems I’ve discovered lesser-known widgets and functionalities that can simplify your development process and add a unique touch to your apps. Moreover, we will go deeper into the implementation and explore how they are implemented to learn more about the patterns.

Let’s uncover some of these widgets together!

Demystifying Union Types in Dart, Tagged vs. Untagged, Once and For All

· 33 min read
Majid Hajian
Developer Advocate

Cover

Over the years and throughout my career, I have written a lot of code in various languages, such as PHP, Python, Javascript, Typescript, Dart, Java, Go, Clojure, and more. All these languages are equally good and have unique aspects that make you approach problem-solving in a certain way.

One concept seems to appear frequently, often in a rather basic manner but in fact quite complicated: Union Types. Some languages naturally support them; in others, it may seem like an impossible task.

In this article, we will be diving deep into Union Types (Untagged and Tagged Unions)—what they are, why they’re helpful, where they fall short, and why, in strongly typed languages like Dart, you might want to reconsider their use. To convey my message better, I will write examples from different languages, including Typescript, F#, PHP, and more.

Without further ado, let’s get started.

Let’s Talk About Memory Leaks In Dart And Flutter

· 22 min read
Majid Hajian
Developer Advocate

Since 2006, when I started working in software development, I have faced the problem of memory leaks, particularly when using languages like Dart. The integration of Streams and asynchronous programming as a default feature in Dart introduces a level of difficulty in addressing this matter.

Memory leaks can be annoying as they are hard to spot and recreate compared to syntax errors or logic bugs that usually show up in the development phase. When it comes to memory leaks in Flutter applications, it's getting even more complex with the addition layers of widgets and controllers combined with listeners over time which may result performance issues or unexpected crashes for users after prolonged use.

Unfortunately, identifying all memory leaks isn't always straightforward when it comes to analysis since memory usage can vary based on runtime behavior patterns; nevertheless, tools like DCM and its Rules can sometimes help detect patterns that lead to memory leaks and prevent such issues.

In this article, we will explore Dart and Flutter memory leaks, how they occur, their significance in coding practices, solution to debug memory leaks and identify them such as DevTools and Leak Tracker and shifting left by relying on static analyzer tools such DCM and how they can prevent such leaks from sneaking into your code base.

Step-by-Step Guide to Integrate DCM with Open Source Dart & Flutter Packages: "Wolt Modal Sheet Use-case"

· 11 min read
Majid Hajian
Developer Advocate

Cover

At DCM, we understand the importance of maintaining a high-quality codebase, especially in a project as widely used as the Wolt Modal Sheet package. This package provides developers with a powerful tool for implementing responsive modals with multiple pages, smooth transitions, and scrollable content within Flutter applications. However, as projects grow and evolve, ensuring code consistency and catching potential bugs early becomes increasingly critical, particularly when maintaining an open-source project that receives multiple pull requests from different contributors.

Before we start, we'd like to mention that we offer a free OSS license for Dart and Flutter open-source packages. Check out our pricing and contact us by clicking the "Looking for OSS license?" button.

In this guide, we will walk you through the process of integrating DCM into the Wolt Modal Sheet package, covering everything from the initial setup to configuring CI pipelines and addressing code issues.

Improving Code Reviews - Tools and Practices for Dart and Flutter Projects

· 11 min read
Majid Hajian
Developer Advocate

Cover

Code reviews are integral to the software development lifecycle, crucial in maintaining code quality and promoting team collaboration. In this blog, I want to explore the importance of code reviews, tools, and practices to enhance the code review process and emphasize best practices specific to Dart and Flutter development. We will also discuss advanced concepts like "Shifting Left" to integrate reviews earlier in the development cycle, minimizing issues before they propagate.

Why more code is not always a bad thing

· 16 min read
Majid Hajian
Developer Advocate

There's a prevailing myth in software development that less code is always better. While concise code can benefit specific contexts, it doesn't necessarily equate to better code. Code quality, maintainability, and readability are often far more important than simply being less.

This article will explore why writing more code can often lead to better software, especially in Dart and Flutter applications. We'll focus on clarity, modularity, flexibility, robustness, and error handling. We'll also discuss the drawbacks of "magic" code and the importance of linting and rules in maintaining code quality.