Minimalist Guide to Flutter Hooks

Maximize your code reuse with Flutter Hooks

Rei
3 min readNov 4, 2020

--

What is Hooks?

Hooks are a new kind of object that manages a Widget life-cycles. They exist for one reason: increase the code-sharing between widgets by removing duplicates.

In this article, I’ll show you how to reduce your boilerplate code using flutter_hooks.

Why this package exists?

StatefulWidget suffers from a big problem: it is very difficult to reuse the logic of say initState or dispose.

The most exciting thing about this package. when you use hooks, you don’t need to worry about like initState and dispose methods in your widget lifecycle. the package will handle them like a boss instead of you.

If you used any controller before, you understand better the pain we suffer.

Motivation

Examples

--

--