Add sqlite store
Optimize android quick action Optimize backup and restore Optimize more details
This commit is contained in:
@@ -2,17 +2,21 @@ import 'package:riverpod/riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
mixin AutoDisposeNotifierMixin<T> on AnyNotifier<T, T> {
|
||||
T get value => state;
|
||||
|
||||
set value(T value) {
|
||||
if (ref.mounted) {
|
||||
state = value;
|
||||
} else {
|
||||
onUpdate(value);
|
||||
}
|
||||
state = value;
|
||||
}
|
||||
|
||||
bool equals(T previous, T next) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(previous, next) {
|
||||
final res = super.updateShouldNotify(previous, next);
|
||||
final res = !equals(previous, next)
|
||||
? super.updateShouldNotify(previous, next)
|
||||
: true;
|
||||
if (res) {
|
||||
onUpdate(next);
|
||||
}
|
||||
@@ -21,31 +25,19 @@ mixin AutoDisposeNotifierMixin<T> on AnyNotifier<T, T> {
|
||||
|
||||
void onUpdate(T value) {}
|
||||
|
||||
void update(T Function(T) builder) {
|
||||
final value = builder(state);
|
||||
this.value = value;
|
||||
void update(T? Function(T) builder) {
|
||||
final res = builder(value);
|
||||
if (res == null) {
|
||||
return;
|
||||
}
|
||||
value = res;
|
||||
}
|
||||
}
|
||||
|
||||
mixin AnyNotifierMixin<T> on AnyNotifier<T, T> {
|
||||
mixin AsyncNotifierMixin<T> on AnyNotifier<AsyncValue<T>, T> {
|
||||
T get value;
|
||||
|
||||
set value(T value) {
|
||||
if (ref.mounted) {
|
||||
state = value;
|
||||
} else {
|
||||
onUpdate(value);
|
||||
}
|
||||
state = AsyncData(value);
|
||||
}
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(previous, next) {
|
||||
final res = super.updateShouldNotify(previous, next);
|
||||
if (res) {
|
||||
onUpdate(next);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void onUpdate(T value) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user