Daily Dev #11 – Write Less, Do More with ...

Daily Dev #11 – Write Less, Do More with Cascade Notation

Aug 14, 2025

Ever feel like your Dart code looks repetitive when setting multiple properties on the same object?

Instead of:

final user = User();

user.name = 'Izzat';

user.email = '[email protected]';

user.isActive = true;

You can do this:

final user = User()

..name = 'Izzat'

..email = '[email protected]'

..isActive = true;

That’s Cascade Notation (..) — it lets you call multiple methods or set properties on the same object without repeating the variable name.

It works with functions too:

final buffer = StringBuffer()

..write('Hello')

..write(' ')

..write('World');

🧠 Takeaway:

> “The .. operator is like multitasking for your objects — clean, concise, and satisfying.”

If this tip made your code a little prettier, maybe fuel the next gem with a coffee:

👉 buymeacoffee.com/ejjat

#darttips #flutterdev #dailydev #cleancode #buymeacoffee

Подобається цей допис?

Купити для Izzat Rizal burger

1 коментар

Більше від Izzat Rizal