stat method Null safety
- [ResponseCallback<
StatResponse> ? callback]
Refreshes the current instances values of address, domain
, didDocument, balance, didUrl, and staked with the latest values from the blockchain. An
optional callback
can be provided to be notified when the refresh is complete.
Example
// Refresh the current account
await MotorFlutter.to.refresh();
print(MotorFlutter.to.address); // prints: 'did:snr:abc123'
print(MotorFlutter.to.balance); // prints: 1000
Next Steps:
- Try sending some SNR to other accounts with sendTokens
- Sonr Technical Documentation
Implementation
Future<StatResponse?> stat([ResponseCallback<StatResponse>? callback]) async {
if (!authorized.value) {
Log.printFlutterWarn("User is not yet authorized");
}
// Wrap instance method with try catch
try {
final resp = await MotorFlutterPlatform.instance.stat();
if (resp != null) {
didDocument(resp.didDocument);
address(resp.address);
balance(resp.balance);
staked(resp.stake.toString());
}
if (callback != null) {
callback(resp);
}
return resp;
} catch (e) {
Log.printMotorException(e.toString());
}
return null;
}