0

I set a variable to an instance of BIP32 in a function, but accessing the varialble in a compute returns null

Map checkRoot(a) {
  print(root); // null
}
Map calculateSeed(String seedPhrase) {
  seed = bip39.mnemonicToSeed(seedPhrase);
  return {'root': bip32.BIP32.fromSeed(seed), 'seed': seed};
}
Future<void> initializeAllPrivateKeys(String mnemonic) async {
  Map seedDetails = await compute(calculateSeed, mnemonic);
  root = seedDetails['root'];
  seed = seedDetails['seed'];
  print(root); // 'Instance of BIP32'
  await compute(checkRoot, '');
}

What I expected

Map checkRoot(a) {
  print(root); // 'Instance of BIP32'
}

TylerH
  • 20,799
  • 66
  • 75
  • 101
Davy King
  • 27
  • 8
  • As mentioned by the [`dart:isolate` documentation](https://api.dart.dev/stable/dart-isolate/dart-isolate-library.html), `Isolate`s don't share memory. (That's what makes them isolated.) – jamesdlin Dec 19 '22 at 08:52
  • so please...how do i acess the variable – Davy King Dec 19 '22 at 09:37

0 Answers0