Make your life easier with extensions.

Simple helpers with big impact on code readability.

What are extensions?

Extensions allow developers to add new functionalities to existing libraries, classes, or types in Dart. Essentially, they enable us to sprinkle some extra magic on the existing code, enhancing its capabilities without modifying it.

Okay, fancy words. Let’s look at a use case.

UI written with Flutter can get quite busy. Here are some tips to make it look way more clean.

Here you can see the two widget doing the exact same thing. However the bottom one is way more streamlined.

And this is the way how we achieve it.

And voilá. That’s all you need.

So put wait, why should I do this?

Imagine your standard Screen. You nest widget within widget. Everytime you make use of something like Theme.of(context) or MediaQuery.of(context) you can just write context.size for example.

Thanks for reading.

Reply

or to participate.