react_hooks 1.0.1
react_hooks: ^1.0.1 copied to clipboard
A Flutter package that provides React-like hooks (useState, useEffect) for state management and side effects in Flutter apps.
Changelog #
1.0.0 - 2025-09-26 #
Added #
- Initial release
- Implemented
useStatehook functionality- Basic state management with multiple syntax styles
- Property access:
countState.value,countState.setValue() - Destructuring to variables:
final count = countState.value; final setCount = countState.setValue; - Tuple style:
countState.$1,countState.$2 - Functional updates:
countState.update((prev) => prev + 1) - Convenience methods:
boolState.toggle()
- Implemented
useEffecthook functionality- Side effect handling and lifecycle management
- Dependency array support:
[],[dep1, dep2],null - Cleanup function support
- Implemented
useMemoanduseCallbackhooks- Performance optimization, caching computation results and callback functions
- Implemented
useContextfor state sharing- Context-based state management across widget tree
ProviderandHookProvidercomponents- Automatic dependency injection
- Implemented convenient useState variants
useBool()- Specialized for boolean values, supportstoggle()useTextEditingController()- For TextField management
HookWidgetbase class andHookBuildercomponent- Complete type definitions and documentation
- Example application demonstrating multiple syntax styles
Features #
- π React-like state management with multiple syntax style support
- β‘ Side effects and lifecycle management
- π― Complete type safety
- π Functional update support
- π§Ή Automatic cleanup mechanism
- π¨ Flexible API design adapting to different development habits
- π‘ Convenient specialized hooks for improved development efficiency
- π Context state sharing capabilities
Technical Implementation #
ChangeNotifier-based state management- Hook context management ensuring hook call order
- Microtask-scheduled side effect execution
- Dependency comparison algorithm for performance optimization
- InheritedWidget-based context propagation