Flutter Component

Aymen Toumi
1 min readMay 4, 2019

--

Flutter is cool, its StatelessWidget is very easy to implement but immutable in the other side StatefulWidget is very powerful but a little bit complicated. In my quest to find an easier way to implement a mutable widget, I developed the Component widget that can be easily implemented as a StatelessWidget and mutable as a StatefulWidget.

Let’s take a look to the code:

I think every thing is clear but perhaps an example will make things more and more clear.

Let’s take the famous counter app that you get when a new Flutter project is created and change it with our component. The final result will be like this:

First, I like to have a mutable title component:

Now, let’s move to the counter component that should be updated every time the FAB clicked and with some opacity animation:

Finally, the main file:

No more to say, try it and if you like it give me a clap. Thanks.

--

--