flutter_hooks 0.3.0-dev.3
flutter_hooks: ^0.3.0-dev.3 copied to clipboard
A flutter implementation of React hooks. It adds a new kind of widget with enhanced code reuse.
0.3.0: #
- NEW: Hooks are now visible on
HookElementthroughdebugHooksin development, for testing purposes. - NEW: If a widget throws on the first build or after a hot-reload, next rebuilds can still add/edit hooks until one
buildfinishes entirely. - NEW: new life-cycle availble on
HookState:didBuild. This life-cycle is called synchronously right afterbuildmethod ofHookWidgetfinished. - NEW: new
reassemblelife-cycle onHookState. It is equivalent toState.ressembleof statefulwidgets. - NEW:
useStreamanduseFuturenow have an optionalpreserveStateflag. This toggle how these hooks behaves when changing the stream/future: If true (default) they keep the previous value, else they reset to initialState.
0.2.1: #
- NEW:
useValueNotifier, which creates aValueNotifiersimilarly touseState. But without listening it. This can be useful to have a more granular rebuild when combined touseValueListenable. - NEW:
useContext, which exposes theBuildContextof the currently buildingHookWidget.
0.2.0: #
- Made all existing hooks as static functions, and removed
HookContext. The migration is as followed:
Widget build(HookContext context) {
final state = context.useState(0);
}
becomes:
Widget build(BuildContext context) {
final state = useState(0);
}
- Introduced keys for hooks and applied them to hooks where it makes sense.
- Added
useReducerfor complex state. It is similar touseStatebut is being managed by aReducerand can only be changed by dispatching an action. - fixes a bug where hot-reload without using hooks throwed an exception
0.1.0: #
useMemoizedcallback doesn't take the previous value anymore (to match React API) UseuseValueChangedinstead.- Introduced
useEffectanduseStreamController - fixed a bug where hot-reload while reordering/adding hooks did not work properly
- improved readme
0.0.1: #
Added a few common hooks:
useStreamuseFutureuseAnimationControlleruseSingleTickerProvideruseListenableuseValueListenableuseAnimation
0.0.0: #
- initial release