grab 0.4.0
grab: ^0.4.0 copied to clipboard
A flutter package providing mixins and extension methods to trigger a rebuild on change in a Listenable (ChangeNotifier, ValueNotifier, etc).
0.4.0 #
- Breaking:
- Replace
BuildContext
extension withListenable
andValueListenable
extensions.- Before
final changeNotifier = MyChangeNotifier(value: 'value'); // With ChangeNotifier final notifier = context.grab<MyChangeNotifier>(changeNotifier); final value = context.grabAt(changeNotifier, (MyChangeNotifier n) => n.value);
final valueNotifier = MyValueNotifier(MyState(value: 'value')); // With ValueNotifier final state = context.grab<MyValueNotifier>(valueNotifier); final value = context.grabAt(valueNotifier, (MyState state) => state.value);
- After
Simply swap the position of BuildContext and Listenable. Types are inferred correctly now with ValueListenable (e.g. ValueNotifier), but not with other Listenables (e.g. ChangeNotifier).// With ChangeNotifier final notifier = changeNotifier.grab<MyChangeNotifier>(context); final value = changeNotifier.grabAt(context, (MyChangeNotifier n) => n.value);
// With ValueNotifier // More type-safe and concise now final state = valueNotifier.grab(context); final value = valueNotifier.grabAt(context, (state) => state.value);
- Before
- Replace
0.3.1 #
- Refactor extension methods.
- Rename a debug property from
grabCounter
tograbCallCounter
. - Simplify tests for maintainability.
0.3.0+1 #
- Fix changelog.
0.3.0 #
- Bump minimum Flutter version to 3.0.0.
- Minor changes.
0.2.2 #
- Remove unnecessary list of previous values from element.
grabValues
was accordingly removed from the debug properties.
- Remove duplicate
_reset()
call. - Additional minor refactoring.
0.2.1 #
- Improve document of mixins.
- Add sample app link to README.
0.2.0 #
- Implement
debugFillProperties()
. - Make
GrabSelector
public. - Refactor GrabMixinError.
- Throw
GrabMixinError
instead ofAssertionError
in debug mode too. - Improve tests.
- Improve documentation.
- Update lint rules.
0.1.0 #
- Improve documentation.
- Require Flutter >=2.10.
0.0.1 #
- Initial version.