mirror of
https://github.com/foss42/apidash.git
synced 2025-10-15 02:37:40 +08:00
Fix provider initialization error
This commit is contained in:
@ -30,9 +30,16 @@ final StateNotifierProvider<CollectionStateNotifier, Map<String, RequestModel>?>
|
|||||||
class CollectionStateNotifier
|
class CollectionStateNotifier
|
||||||
extends StateNotifier<Map<String, RequestModel>?> {
|
extends StateNotifier<Map<String, RequestModel>?> {
|
||||||
CollectionStateNotifier(this.ref, this.hiveHandler) : super(null) {
|
CollectionStateNotifier(this.ref, this.hiveHandler) : super(null) {
|
||||||
loadData();
|
var status = loadData();
|
||||||
Future.microtask(() => ref.read(activeIdStateProvider.notifier).state =
|
Future.microtask(() {
|
||||||
ref.read(requestSequenceProvider)[0]);
|
if (status) {
|
||||||
|
ref.read(requestSequenceProvider.notifier).state = [
|
||||||
|
state!.keys.first,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
ref.read(activeIdStateProvider.notifier).state =
|
||||||
|
ref.read(requestSequenceProvider)[0];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
final Ref ref;
|
final Ref ref;
|
||||||
@ -184,7 +191,7 @@ class CollectionStateNotifier
|
|||||||
state = {};
|
state = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadData() {
|
bool loadData() {
|
||||||
var ids = hiveHandler.getIds();
|
var ids = hiveHandler.getIds();
|
||||||
if (ids == null || ids.length == 0) {
|
if (ids == null || ids.length == 0) {
|
||||||
String newId = uuid.v1();
|
String newId = uuid.v1();
|
||||||
@ -193,7 +200,7 @@ class CollectionStateNotifier
|
|||||||
id: newId,
|
id: newId,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
ref.read(requestSequenceProvider.notifier).state = [newId];
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Map<String, RequestModel> data = {};
|
Map<String, RequestModel> data = {};
|
||||||
for (var id in ids) {
|
for (var id in ids) {
|
||||||
@ -205,6 +212,7 @@ class CollectionStateNotifier
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
state = data;
|
state = data;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user