risk_dfp_flutter 1.0.3
risk_dfp_flutter: ^1.0.3 copied to clipboard
Facilitates secure device info collection and analysis for seamless integration of Risk Detection and Fraud Prevention in Flutter apps, enhancing security.
example/lib/main.dart
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:risk_dfp_flutter/risk_dfp_flutter.dart';
import 'ui/home.dart';
// void main() async {
// await _initHive();
// runApp(const MainApp());
// }
//
void main() async {
await _initHive();
runApp(const MyApp());
}
Future<void> _initHive() async {
await Hive.initFlutter();
await Hive.openBox("login");
await Hive.openBox("accounts");
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FutureBuilder<String>(
future: RiskDfpFlutter.getDeviceFingerPrint,
builder: (_, snapshot) {
final currentContext = context; // Store the context
return ElevatedButton(
style: ElevatedButton.styleFrom(
minimumSize: const Size.fromHeight(50),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
),
onPressed: () async {
await RiskDfpFlutter.submitDeviceFingerPrint({
"userId": "",
"key":
'-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1Xmc3saDtMXK5YxeoLG0\nb2zoLo5tBsc3ClUrTQBMJZwOpDLL/4xDbNODUB9QcsQQCXF6icAgdTOqL51yrGmf\n//u31rg6Huo3Tuwh9OlYg6wKD/3R57IApdUDHeEiOQZgOZ/Ie+Q3d830LSFFIViL\nKh6cfo+wn07zmsAOJvYi6LfTulBdbaEOo9JnZCpMyswf3Wx2Vrhr2TNTBcCyr2RI\nlJc5yW/5+boxRMp+SHjdd0lumlHAFKjx0BBUxez5SIsBExWveMNcCz67g7+P0wJj\nvSxQXUn4QR2XpfY0ZS4V2/Ra2Wscxxou3aKOw9+y7O3nxf36szFNODz4LDT+tYp3\n0wIDAQAB\n-----END PUBLIC KEY-----',
"endpoint":
"https://stgrdx.zalopay.vn/v1/api/gimo/${_getApp()}/dfp",
});
},
child: const Text("Click Me"),
);
},
),
],
),
),
),
);
}
String _getApp() => kIsWeb
? 'Web Browser info'
: switch (defaultTargetPlatform) {
TargetPlatform.android => 'android',
TargetPlatform.iOS => 'ios',
TargetPlatform.linux => 'browser',
TargetPlatform.windows => 'browser',
TargetPlatform.macOS => 'browser',
TargetPlatform.fuchsia => '',
};
}