react_hooks 1.0.0
react_hooks: ^1.0.0 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
useState
hook 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
useEffect
hook functionality- Side effect handling and lifecycle management
- Dependency array support:
[]
,[dep1, dep2]
,null
- Cleanup function support
- Implemented
useMemo
anduseCallback
hooks- Performance optimization, caching computation results and callback functions
- Implemented
useContext
for state sharing- Context-based state management across widget tree
Provider
andHookProvider
components- Automatic dependency injection
- Implemented convenient useState variants
useBool()
- Specialized for boolean values, supportstoggle()
useTextEditingController()
- For TextField management
HookWidget
base class andHookBuilder
component- 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