-
-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathuser_consent_api_example.dart
More file actions
45 lines (35 loc) · 1.06 KB
/
user_consent_api_example.dart
File metadata and controls
45 lines (35 loc) · 1.06 KB
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
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.removeUserConsentApiListener();
}
@override
Future<String?> getSmsCode() async {
final res = await smartAuth.getSmsWithUserConsentApi();
return res.data?.code;
}
@override
bool get listenForMultipleSms => false;
}
class UserConsentApiExample extends StatefulWidget {
const UserConsentApiExample({super.key});
@override
State<UserConsentApiExample> createState() => _UserConsentApiExampleState();
}
class _UserConsentApiExampleState extends State<UserConsentApiExample> {
late final SmsRetrieverImpl smsRetrieverImpl;
@override
void initState() {
smsRetrieverImpl = SmsRetrieverImpl(SmartAuth.instance);
super.initState();
}
@override
Widget build(BuildContext context) {
return Pinput(smsRetriever: smsRetrieverImpl);
}
}