- Add the dependency https://pub.dev/packages/sms_autofill
- your class must implement the mixi CodeAutoFill mixin
- in initstate you should generate the app Signature and listen for the code
@override
void initState() {
listenForCode();
SmsAutoFill().getAppSignature.then((signature) {
setState(() {
appSignature = signature;
print(appSignature);
});
});
super.initState();
}
- In the overriden method
@override
void codeUpdated() {
// TODO: implement codeUpdated
setState(() {
otpController.text = code;
});
verifyOtp(code);
}
@override
void dispose() {
cancel();
if (_shouldDisposeController) {
controller.dispose();
}
unregisterListener();
super.dispose();
}
ANd the bakend should send tge otp in this format
<#> ExampleApp: Your code is 123456
FA+9qCX9VSu
where FA+.. is the appSignature generated in step 3