Skip to content

Commit ee6ffaf

Browse files
committed
Updates:
- Added SMS autofill Migration guide - Added examples - Improved Readme
1 parent 4970eaf commit ee6ffaf

File tree

10 files changed

+344
-473
lines changed

10 files changed

+344
-473
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#### 5.0.0 · 9/04/2024
22
- Implemented Pinput.builder to build custom Pinput fields
33
- Migrated deprecated imperative apply of Flutter's Gradle plugins example app
4-
4+
- Removed smart_auth dependency which was responsible for SMS autofill (Not everyone might need it and it was causing some issues)
5+
- [Migration guide](MIGRATION.md)
56

67
#### 4.0.0 · 10/02/2024
78
- Fixed RECEIVER_EXPORTED exception in android SDK 34 PR

MIGRATION.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#### Migration to 5.0.0+
2+
- If you need SMS autofill on Android, you need to add the smart_auth package directly to your project.
3+
4+
5+
Before 5.0.0:
6+
```dart
7+
class Example extends StatelessWidget {
8+
const Example({Key? key}) : super(key: key);
9+
10+
11+
@override
12+
Widget build(BuildContext context) {
13+
return Pinput(
14+
androidSmsAutofillMethod:
15+
AndroidSmsAutofillMethod.smsUserConsentApi,
16+
listenForMultipleSmsOnAndroid: true,
17+
);
18+
}
19+
}
20+
```
21+
22+
After 5.0.0:
23+
```agsl
24+
dependencies:
25+
smart_auth: 2.0.0
26+
```
27+
28+
```dart
29+
class SmsRetrieverImpl implements SmsRetriever {
30+
const SmsRetrieverImpl(this.smartAuth);
31+
32+
final SmartAuth smartAuth;
33+
34+
@override
35+
Future<void> dispose() {
36+
return smartAuth.removeSmsListener();
37+
}
38+
39+
@override
40+
Future<String?> getSmsCode() async {
41+
final res = await smartAuth.getSmsCode();
42+
if (res.succeed && res.codeFound) {
43+
return res.code!;
44+
}
45+
return null;
46+
}
47+
48+
@override
49+
bool get listenForMultipleSms => false;
50+
}
51+
52+
class SmartAuthExample extends StatefulWidget {
53+
const SmartAuthExample({Key? key}) : super(key: key);
54+
55+
@override
56+
State<SmartAuthExample> createState() => _SmartAuthExampleState();
57+
}
58+
59+
class _SmartAuthExampleState extends State<SmartAuthExample> {
60+
late final SmsRetrieverImpl smsRetrieverImpl;
61+
62+
@override
63+
void initState() {
64+
smsRetrieverImpl = SmsRetrieverImpl(SmartAuth());
65+
super.initState();
66+
}
67+
68+
@override
69+
Widget build(BuildContext context) {
70+
return Pinput(
71+
smsRetriever: smsRetrieverImpl,
72+
);
73+
}
74+
}
75+
```

0 commit comments

Comments
 (0)