flutter_shieldfraud 1.0.11 copy "flutter_shieldfraud: ^1.0.11" to clipboard
flutter_shieldfraud: ^1.0.11 copied to clipboard

Flutter plugin for Shield SDK. SHIELD SDK helps developers to assess malicious activities performed on mobile devices and return risk intelligence based on user's behaviour.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_shieldfraud/plugin_shieldfraud.dart';
import 'package:flutter_shieldfraud/shield_config.dart';
import 'dart:convert';

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> {
  String jsonString = "";

  @override
  void initState() {
    super.initState();

    initShield();

    Future.delayed(const Duration(seconds: 2), () async {
      Shield.latestDeviceResult.then((latestDeviceResult) => {
            if (latestDeviceResult == null)
              {print("error ${Shield.latestError?.message}")}
            else
              {print("result $latestDeviceResult")}
          });
    });
  }

  Future<void> initShield() async {
    ShieldCallback shieldCallback =
        ShieldCallback((Map<String, dynamic> result) {
      setState(() {
        jsonString = const JsonEncoder.withIndent('  ').convert(result);
      });

      print("callback result: $result");
    }, (ShieldError error) {
      print("callback error: ${error.message}");
    });
    var data = <String, String>{};
    data["user_id"] = "12345";
    final valueInt = await Shield.isShieldInitialized;
    ShieldConfig config = ShieldConfig(
        siteID: "SHIELD_SITE_ID",
        key: "SHIELD_SECRET_KEY",
        shieldCallback: shieldCallback,
        environment: ShieldEnvironment.prod,
        logLevel: ShieldLogLevel.debug);
    if (!valueInt) {
      Shield.initShield(config);
      Future.delayed(const Duration(seconds: 2), () async {
        final valueInt = await Shield.isShieldInitialized;
        if (valueInt) {
          Shield.sendAttributes("login", data);
        }
      });
    } else {
      Shield.sendAttributes("login", data);
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: const Text('Plugin example app'),
          ),
          body: Column(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Expanded(
                child: Text(jsonString, key: const Key('jsonString')),
              ),
              SizedBox(
                height: 100,
                width: double.infinity,
                child: MaterialButton(
                  onPressed: () {
                    Shield.sendDeviceSignature("test sending device signature")
                        .then((value) => print(
                            "sending device signature in real time successful: $value"));
                  },
                  child: const Text("Send attributes"),
                ),
              ),
            ],
          )),
    );
  }
}
4
likes
140
pub points
80%
popularity

Publisher

unverified uploader

Flutter plugin for Shield SDK. SHIELD SDK helps developers to assess malicious activities performed on mobile devices and return risk intelligence based on user's behaviour.

Homepage

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_shieldfraud