flutter_threatmetrix_module 0.0.10 copy "flutter_threatmetrix_module: ^0.0.10" to clipboard
flutter_threatmetrix_module: ^0.0.10 copied to clipboard

Flutter plugin to integrate tmx with flutter android and ios apps.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:flutter_threatmetrix_module/flutter_threatmetrix_module.dart';

void main() async {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  Map<String, String>? _profileData;
  String? _error;

  final _flutterThreatmetrixModulePlugin = FlutterThreatmetrixModule();

  @override
  void initState() {
    super.initState();
    initPlatformState();
    getProfilingData();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      platformVersion =
          await _flutterThreatmetrixModulePlugin.getPlatformVersion() ??
              'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  Future<void> getProfilingData() async {
    Map<String, String>? profileData;
    String? error;
    String sessionId = 'a74b23f6021ba8a30066a2dd14d8867da8c6dc19';
    String orgId = 'cihp0vsp';
    String fpServer = 'h-sdk.online-metrix.net';

    try {
      final result = await _flutterThreatmetrixModulePlugin.getProfilingData(
              sessionId, orgId, fpServer) ??
          'No Data';
      print('heelloooo');
      print('${result}result');
      profileData = result as Map<String, String>?;
    } on PlatformException catch (e) {
      error = e.message;
    }

    if (mounted) {
      setState(() {
        _profileData = profileData;
        _error = error;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('Running on: $_platformVersion\n'),
              Text('Profiling data: $_profileData')
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
0
points
36
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter plugin to integrate tmx with flutter android and ios apps.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_threatmetrix_module

Packages that implement flutter_threatmetrix_module