Future<void> handleSigningFlow() async {
try {
final String sig = await BmoniEmbeddedSdk.signMessage(
'Hello',
pin: userEnteredPin,
);
onSuccess(sig);
} on BmoniSignerException catch (e) {
switch (e.errorCode) {
case BmoniSignerErrorCode.pinNotSet:
// Redirect the user to the PIN setup flow.
break;
case BmoniSignerErrorCode.pinMismatch:
// Ask the user to re-enter their PIN.
break;
case BmoniSignerErrorCode.pinInvalid:
// PIN was the wrong length or empty.
break;
case BmoniSignerErrorCode.walletAlreadyExists:
// Only thrown by initWallet — show a re-provision dialog.
break;
default:
// Native or bridge error — log and show a generic message.
debugPrint('Unexpected SDK error: ${e.message} (${e.errorCode})');
}
}
}