createAccount method Null safety

dynamic createAccount(
  1. {required String password,
  2. HandleKeysCallback? onKeysGenerated}
)

Implementation

createAccount({required String password, HandleKeysCallback? onKeysGenerated}) async {
  // Set status to loading
  change(null, status: RxStatus.loading());
  _stopwatch.start();
  Timer.periodic(const Duration(milliseconds: 125), _handleTimer);

  // Create account
  final res = await MotorFlutter.to.createAccount(password, onKeysGenerated: onKeysGenerated);
  if (res == null) {
    _closeTimer();
    change(null, status: RxStatus.error("Internal Error - Failed to create account"));
    return;
  }

  // Set account address
  _closeTimer();
  accountAddress(res.address);
  change(res, status: RxStatus.success());
}