Skip to main content

Let’s Talk About Memory Leaks In Dart And Flutter

· 21 min read
Majid Hajian
Google Developer Expert

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.

What’s new in DCM 1.23.0

· 11 min read

Cover

Today we’re excited to announce the release of DCM 1.23.0!

This release includes 9 new rules, 9 new quick fixes for existing rules, new command for analyzing assets for various issues, detection of duplicate test cases, reworked rules documentation and much more! 🚀

warning

❗️ the "--monorepo" flag was replaced with "--exclude-public-api", and now the default behavior for commands is if the "--monorepo" flag is passed

Let's go through the highlights of this release! (And you can find the full list of changes in our changelog)

What’s new in DCM 1.22.0

· 8 min read

Cover

Today we’re excited to announce the release of DCM 1.22.0!

This release includes 15 new rules, DCM Teams Console improvements, ignore comment support for pubspec rules and the first version of our public roadmap.

info

In the next release we'll update the recommended preset to include new rules. If you use this preset, please be ready to address new warnings.

Let's go through the highlights of this release! (And you can find the full list of changes in our changelog)

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

· 10 min read
Majid Hajian
Google Developer Expert

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.

What’s new in DCM 1.21.0

· 9 min read

Cover

Today we’re excited to announce the release of DCM 1.21.0!

This release includes 9 new rules, a reworked "banned-usage" rule, a new reporter format for SonarQube, a new "Guides" section in the documentation, and general UX improvements 🚀.

warning

❗️ "banned-usage" now works only for usages (e.g., method invocations or property accesses); use "avoid-banned-names" to ban declaration names

❗️ "ban-name" has been removed; use "avoid-banned-names" instead

Let's go through the highlights of this release! (And you can find the full list of changes in our changelog)

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

· 10 min read
Majid Hajian
Google Developer Expert

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

· 15 min read
Majid Hajian
Google Developer Expert

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.

What’s new in DCM 1.19.0

· 10 min read

Cover

Today we’re excited to announce the release of DCM 1.19.0!

This release includes 9 new rules (4 for Riverpod), proper support for codegen packages by the check-dependencies command, new summary output to sdterr for various reporters, new visualization of the statically resolved widget trees for analyze-widgets, new fix type for removing unused files (moved from check-unused-files), documentation updates and other DX improvements! 🚀

Let's go through the highlights of this release! (And you can find the full list of changes in our changelog)

Ensuring Consistent and High-Quality Code In Dart and Flutter Projects Through Continuous Integration (CI)

· 9 min read
Majid Hajian
Google Developer Expert

Maintaining consistent and high-quality code is necessary in the fast-paced software development world, especially in Flutter and Dart projects, as they are known for being speedy tools. Continuous Integration (CI) has emerged as a crucial practice that helps development teams achieve this goal. CI provides rapid feedback by integrating code frequently and automating various aspects of the development process, allowing teams to identify and rectify issues early.

ChallengesChallenges

This article explores the significance of CI in enforcing code quality and consistency, the role of lint tools, especially DCM, and practical examples of integrating these tools with CI pipelines.

What’s new in DCM 1.18.0

· 9 min read

Cover

Today we’re excited to announce the release of DCM 1.18.0!

This release includes 8 new rules, improved "New Version" notifications, new grouping option for IntelliJ plugin, automatic DCM version detection by the "setup-dcm" action and general UX improvements 🚀.

warning

❗️ All DCM versions prior to 1.11.0 have been discontinued.

❗️ "check-unnecessary-nullable" command has been removed.

Let's go through the highlights of this release! (And you can find the full list of changes in our changelog)

Enhancing Flutter/Dart code quality with pre-commit hooks

· 8 min read
Olivier Revial
Lead mobile developer at Steeple

Enhancing Flutter/Dart code quality with pre-commit hooks

On any real-world Flutter project (but any project, really...), you want to run an analyzer and a linter at some point to ensure your quality matches the baseline your team agreed on. If you've been following me for some time, you might know that I love a promising CI/CD pipeline (heck, I even wrote a series on the topic 🙃). I always recommend running these checks in your CI pipeline.

What’s new in DCM 1.17.0

· 11 min read

Cover

Today we’re excited to announce the release of DCM 1.17.0!

This release includes 9 new rules (3 for Riverpod 🔥), early access to the DCM Teams license management portal, per-package monorepo mode, global configuration with DCM version constrains and more 🚀.

info

The recommended preset has been updated and now includes some rules from 1.14.0, 1.15.0 and 1.16.0, so you may get new warnings if you use the build-in recommended preset or once you update the dart-code-metrics-presets package dependency.

warning

❗️ With the next release we plan to discontinue all DCM versions prior to 1.11.0.

If you're still using one of those, consider upgrading to a newer version.

Let's go through the highlights of this release! (And you can find the full list of changes in our changelog)

What’s new in DCM 1.16.0

· 7 min read

Cover

Today we’re excited to announce the release of DCM 1.16.0!

This release includes 2 new commands (one for the advanced analysis of parameters and another one for the project structure analysis), 5 new rules, UX improvements and more. 🚀

Let's go through the highlights of this release! (And you can find the full list of changes in our changelog)

What’s new in DCM 1.15.0

· 10 min read

Cover

Today we’re excited to announce the release of DCM 1.15.0!

This release includes extension types support for all existing rules and features, 13 new rules (4 for extension types), 30 new quick fixes (some of them are available via dcm fix), Checkstyle format for all available commands, UX improvements and more. 🚀

Let's go through the highlights of this release!

What’s new in DCM 1.14.0

· 9 min read

Cover

Today we’re excited to announce the release of DCM 1.14.0!

This release includes a new command to find duplicate functions, methods and constructors, new built-in preset to avoid installing an additional package, 4 new rules, and more 🚀.

info

The recommended preset now has new rules from 1.13.0, so you may get new warnings once you update the dart-code-metrics-presets package dependency.

Now let's go through the highlights of this release 🚀.