Flutter_Pinput
Flutter_Pinput copied to clipboard
Remove `smart_auth` / Make an UI widget only
The package currently relies on smart_auth for automatic verifications. Some users might only want the interface for their implementations like local PIN inputs, which do not use receivers or listeners.
Same issues
Good idea but how would you remove smart_auth from Pinput without messing up developer's day :D?
Good idea but how would you remove smart_auth from Pinput without messing up developer's day :D?
Probably go with a new package flutter_pinput. It's not occupied yet. :)
@AlexV525 I'm thinking of something like this:
I'll create a interface SmsRetriever and add it as a Pinput property
abstract class SmsRetriever {
bool get listenForMultipleSms;
Future<String?> getSmsCode();
Future<void> removeSmsListener();
}
class Pinput extends StatefulWidget {
const Pinput({
this.smsRetriever,
/// ...other params
});
}
In the main app, developers have to implement the SmsRetriever, which can use smart_auth or any other library for reading sms code
class SmsRetrieverImpl implements SmsRetriever {
const SmsRetrieverImpl(this.smartAuth);
final SmartAuth smartAuth;
@override
Future<void> removeSmsListener() {
return smartAuth.removeSmsListener();
}
@override
Future<String?> getSmsCode() async {
final res = await smartAuth.getSmsCode();
if (res.succeed && res.codeFound) {
return res.code!;
}
return null;
}
@override
bool get listenForMultipleSms => false;
}
And finally, you can create a Pinput widget:
Pinput(
smsRetriever: SmsRetrieverImpl(
SmartAuth(),
),
);
WDYT?
WDYT?
I haven't looked into the implementation, but the idea looks great overall. Some bonus points might be using the interface class modifiers if you've already limited the lower bound of the Dart SDK. And thanks for sharing your thoughts!
The idea is great wanted to try it out
Due to regulatory review requirements, we cannot integrate additional SDKs within our app... Pure ui widget is a good idea
This seems to have been implemented in v5.0.0. Cheers!
https://github.com/Tkko/Flutter_PinPut/blob/master/MIGRATION.md#migration-to-500