okhi_flutter 1.1.16 okhi_flutter: ^1.1.16 copied to clipboard
The OkHi Flutter library will enable you to start collecting and verifying your user's addresses.
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:okhi_flutter/models/okhi_verification_types.dart';
import 'package:okhi_flutter/okhi_flutter.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
final config = OkHiAppConfiguration(
branchId: "<my_branch_id>",
clientKey: "<my_client_key_id>",
env: OkHiEnv.sandbox,
notification: OkHiAndroidNotification(
title: "Verification in progress",
text: "Verifying your address",
channelId: "okhi",
channelName: "OkHi",
channelDescription: "Verification alerts",
),
);
OkHi.initialize(config).then((result) {
if (kDebugMode) {
print(result);
}
}).onError((error, stackTrace) {
if (kDebugMode) {
print(error);
}
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text("Create an address"),
),
body: OkHiLocationManager(
user: OkHiUser(phone: "+254712000000"),
configuration: OkHiLocationManagerConfiguration(
verificationTypes: [VerificationTypes.digital]
),
onSucess: (response) {
response.startVerification(null);
},
onError: (error) {
if (kDebugMode) {
print(error.code);
print(error.message);
}
},
),
),
);
}
}