fraud_sdk_flutter 1.0.17
fraud_sdk_flutter: ^1.0.17 copied to clipboard
A wrapper of fraud-sdk android in flutter
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:fraud_sdk_flutter/fraud_sdk_flutter.dart';
import 'package:fraud_sdk_flutter/model/options.dart';
import 'package:fraud_sdk_flutter_example/utils/log.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String initValue = "";
String stop = "";
String sessionID = "";
String intelligenceResponse = "";
@override
void initState() {
super.initState();
initSign3Sdk();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: SingleChildScrollView(
child: Column(
children: [
Column(
children: [
Text("INIT: $initValue"),
// Text("STOP: $stop"),
Text("SESSION ID: $sessionID"),
Text("INTELLIGENCE RESPONSE: $intelligenceResponse")
],
),
Row(
children: [
ElevatedButton(
onPressed: () async {
await getIntelligence();
},
child: const Text("Get Intelligence")
)
],
),
],
),
),
),
);
}
Options getOptions() {
Options options = OptionsBuilder()
.setClientId('test_tenant')
.setClientSecret("secret-295OzNJj9L3nVUWQq56ACCN6f6zUiYGQlN8G7256")
.setEnvironment(Environment.DEV) // Assume 'Environment' enum exists
.build();
return options;
}
Future<void> initSign3Sdk() async {
// You don't need to call the stop function, as it's specific to the Native Android Application class. When the isolated service starts, it calls the Android Application class's onCreate method. However, in Flutter, there is no Application class, so there's no need to call it.
// Sign3IntelligencePlugin.cancelAllWorkers();
// var stopResult = (await Sign3IntelligencePlugin.stop());
// if(stopResult) {
// Log.i("TAG_STOP: ", "$stopResult");
// return;
// }else{
// Log.i("TAG_STOP: ", "$stopResult");
// }
var init = await Sign3IntelligencePlugin.initAsync(getOptions().toMap());
Log.i("TAG_INIT: ", "$init");
var id = await Sign3IntelligencePlugin.getSessionId();
Log.i("TAG_SESSION_ID: ", id);
setState(() {
initValue = init.toString();
// stop = stopResult.toString();
sessionID = id;
});
}
Future<void> getIntelligence() async {
try {
var map = await Sign3IntelligencePlugin.getIntelligence();
intelligenceResponse = map.toString();
Log.i("TAG_GET_INTELLIGENCE", intelligenceResponse);
setState(() {
intelligenceResponse = map.toString();
});
} catch (e) {
Log.i("TAG_GET_INTELLIGENCE_ERROR", e.toString());
}
}
}