Skip to content

Commit

Permalink
Updates:
Browse files Browse the repository at this point in the history
- Added SMS autofill Migration guide
- Added examples
- Improved Readme
  • Loading branch information
Tkko committed Jun 6, 2024
1 parent 4970eaf commit ee6ffaf
Show file tree
Hide file tree
Showing 10 changed files with 344 additions and 473 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#### 5.0.0 · 9/04/2024
- Implemented Pinput.builder to build custom Pinput fields
- Migrated deprecated imperative apply of Flutter's Gradle plugins example app

- Removed smart_auth dependency which was responsible for SMS autofill (Not everyone might need it and it was causing some issues)
- [Migration guide](MIGRATION.md)

#### 4.0.0 · 10/02/2024
- Fixed RECEIVER_EXPORTED exception in android SDK 34 PR
Expand Down
75 changes: 75 additions & 0 deletions MIGRATION.md
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,
);
}
}
```
Loading

0 comments on commit ee6ffaf

Please sign in to comment.