Dart & Flutter Easy Wins 8-14

I recently started a series of daily tweets about easy ways to improve your Dart & Flutter code. I called this Easy Wins.

To make these easier to find, I'm sharing 7 tips every week here on my website.

Entire series here:

8. Use a `finally` block for code that should be executed *both* on success and failure.

Use a `finally` block for code that should be executed **both** on success and failure.
Use a `finally` block for code that should be executed **both** on success and failure.

9. Implement `toString()` in your classes to improve the debugging experience.

Implement `toString()` in your classes to improve the debugging experience.
Implement `toString()` in your classes to improve the debugging experience.

10. Use the if-null operator to provide a fallback for null values.

Use the if-null operator to provide a fallback for null values.
Use the if-null operator to provide a fallback for null values.

11. Use multi-line strings to represent large blocks of text.

Use multi-line strings to represent large blocks of text.
Use multi-line strings to represent large blocks of text.

12. String literals can use 'single' or "double" quotes as delimiters. Escape special characters with a backslash (\), or use raw strings.

String literals can use single or double quotes as delimiters. Escape special characters with a backslash (\), or use raw strings.
String literals can use single or double quotes as delimiters. Escape special characters with a backslash (\), or use raw strings.

13. Use triple slashes to generate documentation comments.

Use triple slashes to generate documentation comments.
Use triple slashes to generate documentation comments.

14. Want to auto-generate hashCode, == and toString() implementations for your classes? Use the Equatable package:

Want to auto-generate hashCode, == and toString() implementations for your classes? Use the Equatable package:
Want to auto-generate hashCode, == and toString() implementations for your classes? Use the Equatable package:

More tips coming next week. Subscribe via RSS for updates!

Happy coding!

Want More?

Invest in yourself with my high-quality Flutter courses.

The Complete Dart Developer Guide

The Complete Dart Developer Guide

Learn Dart Programming in depth. Includes: basic to advanced topics, exercises, and projects. Fully updated to Dart 2.15.

Flutter Animations Masterclass - Full Course

Flutter Animations Masterclass - Full Course

Master Flutter animations and build a completely custom habit tracking application.

Flutter & Firebase Course: Build a Complete App for iOS & Android

Flutter & Firebase Course: Build a Complete App for iOS & Android

A full course with in-depth content, taking you from the basics all the way up to more advanced topics.

Flutter REST API Crash Course

Flutter REST API Crash Course

Build a Coronavirus Tracking App, and learn how to use REST APIs in Flutter.

Get the best Flutter tutorials, right in your inbox.

Join over 16,000 developers who receive my weekly Flutter email course & newsletter:

No spam, ever. Unsubscribe at any time.