Source
Future init() async {
if (_initCalled) {
return;
}
_initCalled = true;
if (provider == null) {
provider = new SimpleNodeProvider(null, profiles);
(provider as SimpleNodeProvider).setPersistFunction(save);
}
if (loadNodes && provider is SerializableNodeProvider) {
if (!(await dataStore.has("dsa_nodes"))) {
(provider as SerializableNodeProvider).init(defaultNodes);
} else {
var decoded = DsJson.decode(await dataStore.get("dsa_nodes"));
if (decoded is Map<String, dynamic>) {
(provider as SerializableNodeProvider).init(decoded);
}
}
} else {
(provider as SerializableNodeProvider).init(defaultNodes);
}
// move the waiting part of init into a later frame
// we need to make sure provider is created at the first frame
// not affected by any async code
await initLinkWithPrivateKey();
}