-
-
Notifications
You must be signed in to change notification settings - Fork 180
/
Copy pathuser_consent_api_example.dart
52 lines (42 loc) · 1.15 KB
/
user_consent_api_example.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import 'package:flutter/material.dart';
import 'package:pinput/pinput.dart';
import 'package:smart_auth/smart_auth.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(
useUserConsentApi: true,
);
if (res.succeed && res.codeFound) {
return res.code!;
}
return null;
}
@override
bool get listenForMultipleSms => false;
}
class UserConsentApiExample extends StatefulWidget {
const UserConsentApiExample({Key? key}) : super(key: key);
@override
State<UserConsentApiExample> createState() => _UserConsentApiExampleState();
}
class _UserConsentApiExampleState extends State<UserConsentApiExample> {
late final SmsRetrieverImpl smsRetrieverImpl;
@override
void initState() {
smsRetrieverImpl = SmsRetrieverImpl(SmartAuth());
super.initState();
}
@override
Widget build(BuildContext context) {
return Pinput(
smsRetriever: smsRetrieverImpl,
);
}
}