Set Variable is null in compute function

101 views Asked by At

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'
}

0

There are 0 answers