-
-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added SMS autofill Migration guide - Added examples - Improved Readme
- Loading branch information
Showing
10 changed files
with
344 additions
and
473 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#### Migration to 5.0.0+ | ||
- If you need SMS autofill on Android, you need to add the smart_auth package directly to your project. | ||
|
||
|
||
Before 5.0.0: | ||
```dart | ||
class Example extends StatelessWidget { | ||
const Example({Key? key}) : super(key: key); | ||
@override | ||
Widget build(BuildContext context) { | ||
return Pinput( | ||
androidSmsAutofillMethod: | ||
AndroidSmsAutofillMethod.smsUserConsentApi, | ||
listenForMultipleSmsOnAndroid: true, | ||
); | ||
} | ||
} | ||
``` | ||
|
||
After 5.0.0: | ||
```agsl | ||
dependencies: | ||
smart_auth: 2.0.0 | ||
``` | ||
|
||
```dart | ||
class SmsRetrieverImpl implements SmsRetriever { | ||
const SmsRetrieverImpl(this.smartAuth); | ||
final SmartAuth smartAuth; | ||
@override | ||
Future<void> dispose() { | ||
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; | ||
} | ||
class SmartAuthExample extends StatefulWidget { | ||
const SmartAuthExample({Key? key}) : super(key: key); | ||
@override | ||
State<SmartAuthExample> createState() => _SmartAuthExampleState(); | ||
} | ||
class _SmartAuthExampleState extends State<SmartAuthExample> { | ||
late final SmsRetrieverImpl smsRetrieverImpl; | ||
@override | ||
void initState() { | ||
smsRetrieverImpl = SmsRetrieverImpl(SmartAuth()); | ||
super.initState(); | ||
} | ||
@override | ||
Widget build(BuildContext context) { | ||
return Pinput( | ||
smsRetriever: smsRetrieverImpl, | ||
); | ||
} | ||
} | ||
``` |
Oops, something went wrong.