DEV Community

Cover image for ✨ Day 1 of #100DaysOfFlutter #iamapuneet
Puneet Sharma
Puneet Sharma

Posted on

✨ Day 1 of #100DaysOfFlutter #iamapuneet

🔹 Topic: Null-Aware Children in a Stack 🧱
Welcome to Day 1 of my #100DaysOfFlutter journey! 🎉
Each day, I’ll be sharing a quick tip, concept, or best practice to help developers — beginners or experienced — write cleaner and smarter Flutter code.

🧠 Today’s Insight: Null-Aware Children in a Stack Widget
In Flutter, it’s common to conditionally render widgets — especially in complex UIs.
But here's a mistake many devs make: adding a widget that might be null directly inside a widget tree like Stack.

This can lead to unexpected behavior or runtime issues.

✅ Instead: Use a null check or conditional rendering before adding it to the children list.

💡 Why it matters:
Keeps your widget tree clean

Avoids unnecessary rendering

Fully leverages Dart’s null safety

Prevents runtime exceptions

Top comments (0)