React-style hooks for Flutter widgets
open sourceMITfree
Flutter Hooks brings React's hooks to Flutter: hooks are objects that manage part of a widget's life cycle, so logic that would sit in a StatefulWidget's initState, didUpdateWidget and dispose (an AnimationController, a TextEditingController, a stream subscription) can be written once and reused across widgets. It ships hooks for state, memoised values, effects, futures and streams, animations, listenables and many Material and Cupertino controllers, and you can write your own. Written by Remi Rousselet.
Problems it solves
- reuse AnimationController setup and disposal across Flutter widgets without copying code
- stop writing StatefulWidget boilerplate just to hold a TextEditingController
- React-style hooks in my Flutter app
Features
- HookWidget, a widget that can use hooks
- useState, useMemoized, useEffect, useRef and other primitives
- hooks for futures and streams (useFuture, useStream)
- useAnimationController and other animation hooks
- hooks for Material and Cupertino controllers (useTextEditingController, useTabController)
- write your own hooks
