oref 2.2.0
oref: ^2.2.0 copied to clipboard
A reactive state management library for Flutter that adds magic to any Widget with signals, computed values, and effects powered by alien_signals.
Oref #
A high-performance Flutter state management tool built with alien_signals
, Oref is one of the fastest Flutter signals and state management solutions.
Overview #
Much of the pain in state management in Dart & Flutter comes from reacting to changes in given values, because the values themselves are not directly observable. We have to use StatefulWidget
or other state management tools for state, which use inefficient proactive notifications or a large number of watchers to notify widgets to rebuild, and the boilerplate code is very redundant.
The release of alien_signals
completely changed Flutter's inefficient state management situation, but Flutter state libraries still require a lot of boilerplate code! Oref completely changes this situation. In Flutter, when a Widget accesses a signal value, if that signal's value changes, the Widget is automatically rebuilt.
class Counter extends StatelessWidget {
@override
Widget build(BuildContext context) {
final count = signal(context, 0);
void increment() => count(count() + 1);
return Column(children: [
Text('Count: ${count()}'),
TextButton(
onPressed: increment,
child: Text('click me'),
)
]);
}
}
Signals are magically injected into the BuildContext to provide optimal performance and ergonomic design. In the example above, we access count()
to get the current value of the signal and complete the responsive binding with the current Counter
. When the count value is updated, it automatically notifies the Counter to rebuild.
Installation #
You can install by editing your pubspec.yaml
file:
dependencies:
oref: any
Or install by running this command:
flutter pub add oref
Documentation #
You can view details through the API Reference in pub.flutter-io.cn or source code comments.
Sponsors #
Oref is an MIT licensed open source project with its ongoing development made possible entirely by the support of these awesome backers. If you'd like to join them, please consider sponsoring Seven(@medz) development.
Contributing #
Thank you to all the people who already contributed to Oref!