fs_anti_theft_flutter 1.1.0+1 copy "fs_anti_theft_flutter: ^1.1.0+1" to clipboard
fs_anti_theft_flutter: ^1.1.0+1 copied to clipboard

unlisted

Package do antitheft.

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fs_anti_theft_flutter/fs_anti_theft_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> {
  static const _methodChanelName = 'fs_anti_theft_sdk';
  bool isProd = true;
  static const MethodChannel _channel = MethodChannel(_methodChanelName);
  static const _alarm = "locationPermission";

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Builder(builder: (context) {
        return Scaffold(
          appBar: AppBar(
            title: const Text('FS Anti Theft Plugin'),
          ),
          body: SingleChildScrollView(
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: Column(
                children: [
                  button(
                    text: "FS Anti Theft SDK",
                    onPressedCheck: () async {
                      var check = await FsAntiTheftPlugin.startLoginToSDK(
                        arguments: {
                          "BASE_URL":
                              "https://us-central1-protecao-pix-homol.cloudfunctions.net/backend/",
                          "APPLICATION_ID": "ayGMxEcU7hA5E7uZshPcSM",
                          "ANTI_THEFT_API_KEY":
                              "381bb4ee-7ef9-48c9-92be-d9ff05a9364d",
                          "VERSION_NAME": "ANDROID",
                          "EMAIL": "renan.delfanti@exa.com.br",
                          "MOBILE": "5516981699612",
                          "IMEI": "",
                          "ANDROID_PACKAGE_NAME": "br.com.fs.pix.security",
                          "DEVICE_CUSTOM_ID":
                              "b6f599be-de9f-4af4-9178-d55d0f3deed2"
                        },
                      );
                      showSnackBar(
                          context: context,
                          message: 'FS Anti Theft SDK $check');
                    },
                  ),
                  button(
                    text: 'All',
                    onPressedReq: () async {
                      FsAntiTheftPlugin.requestAllPermission();
                    },
                    onPressedCheck: () async {
                      var result = await FsAntiTheftPlugin.checkAllPermission();
                      showSnackBar(
                          context: context,
                          message: 'All $result',
                          duration: const Duration(seconds: 5));
                    },
                  ),
                  button(
                    text: 'Location',
                    onPressedReq: () async {
                      FsAntiTheftPlugin.requestPermission(
                          permissionName: EnumPermissionsName.location);
                    },
                    onPressedCheck: () async {
                      var result = await FsAntiTheftPlugin.checkPermission(
                          permissionName: EnumPermissionsName.location);
                      showSnackBar(
                          context: context, message: 'Location $result');
                    },
                  ),
                  button(
                    text: 'Camera',
                    onPressedReq: () async {
                      FsAntiTheftPlugin.requestPermission(
                          permissionName: EnumPermissionsName.camera);
                    },
                    onPressedCheck: () async {
                      var result = await FsAntiTheftPlugin.checkPermission(
                          permissionName: EnumPermissionsName.camera);
                      showSnackBar(context: context, message: 'Camera $result');
                    },
                  ),
                  button(
                    text: 'Notification',
                    onPressedReq: () async {
                      FsAntiTheftPlugin.requestPermission(
                          permissionName: EnumPermissionsName.notification);
                    },
                    onPressedCheck: () async {
                      var result = await FsAntiTheftPlugin.checkPermission(
                          permissionName: EnumPermissionsName.notification);
                      showSnackBar(
                          context: context, message: 'Notification $result');
                    },
                  ),
                  if (Platform.isAndroid)
                    button(
                      text: 'Overlay',
                      onPressedReq: () async {
                        FsAntiTheftPlugin.requestPermission(
                            permissionName: EnumPermissionsName.screenOverlay);
                      },
                      onPressedCheck: () async {
                        var result = await FsAntiTheftPlugin.checkPermission(
                            permissionName: EnumPermissionsName.screenOverlay);
                        showSnackBar(
                            context: context, message: 'Overlay $result');
                      },
                    ),
                  if (Platform.isAndroid)
                    button(
                      text: 'Admin',
                      onPressedReq: () async {
                        FsAntiTheftPlugin.requestPermission(
                            permissionName: EnumPermissionsName.adminAccess);
                      },
                      onPressedCheck: () async {
                        var result = await FsAntiTheftPlugin.checkPermission(
                            permissionName: EnumPermissionsName.adminAccess);
                        showSnackBar(
                            context: context, message: 'Admin $result');
                      },
                    ),
                  if (Platform.isAndroid)
                    buttonMethod(
                        text: 'Alarm On',
                        text2: 'Alarm Off',
                        onPressed1: () async {
                          var result = await FsAntiTheftPlugin.actionAntitheft(
                              actions: EnumActions.alarmOn);
                          showSnackBar(
                              context: context, message: 'Alarm $result');
                        },
                        onPressed2: () async {
                          var result = await FsAntiTheftPlugin.actionAntitheft(
                              actions: EnumActions.alarmOff);
                          showSnackBar(
                              context: context, message: 'Alarm $result');
                        },
                        boolean: true),
                  buttonMethod(
                      text: 'Camera',
                      text2: 'Location',
                      onPressed1: () async {
                        var result = await FsAntiTheftPlugin.actionAntitheft(
                            actions: EnumActions.camera);
                        showSnackBar(
                            context: context, message: 'Alarm $result');
                      },
                      onPressed2: () async {
                        var result = await FsAntiTheftPlugin.actionAntitheft(
                            actions: EnumActions.location);
                        showSnackBar(
                            context: context, message: 'Alarm $result');
                      },
                      boolean: true),
                  buttonMethod(
                      text: 'Remote Loking',
                      text2: 'Remote Unloking',
                      onPressed1: () async {
                        var result = await FsAntiTheftPlugin.actionAntitheft(
                          actions: EnumActions.remoteLoking,
                        );
                        showSnackBar(
                            context: context, message: 'Alarm $result');
                      },
                      onPressed2: () async {
                        var result = await FsAntiTheftPlugin.actionAntitheft(
                            actions: EnumActions.remoteUnloking);
                        showSnackBar(
                            context: context, message: 'Alarm $result');
                      },
                      boolean: true),
                  buttonMethod(
                      text: 'Panic on',
                      text2: 'Panic off',
                      onPressed1: () async {
                        var result = await FsAntiTheftPlugin.actionAntitheft(
                          actions: EnumActions.panicOn,
                        );
                        showSnackBar(
                            context: context, message: 'panicOn $result');
                      },
                      onPressed2: () async {
                        var result = await FsAntiTheftPlugin.actionAntitheft(
                            actions: EnumActions.panicOff);
                        showSnackBar(
                            context: context, message: 'panicOff $result');
                      },
                      boolean: true),
                  // buttonMethod(
                  //     text: 'Remote LockWithout Override',
                  //     text2: 'Remote Wipe',
                  //     onPressed1: () async {
                  //       var result = await FsAntiTheftPlugin.actionAntitheft(
                  //           actions: EnumActions.remoteLockWithoutOverride);
                  //       showSnackBar(context: context, message: 'Alarm $result');
                  //     },
                  //     onPressed2: () async {
                  //       var result = await FsAntiTheftPlugin.actionAntitheft(
                  //           actions: EnumActions.remoteWipe);
                  //       showSnackBar(context: context, message: 'Alarm $result');
                  //     },
                  //     boolean: true),
                  button(
                      text: 'Get device id',
                      onPressedReq: () async {
                        var result = await FsAntiTheftPlugin.getDeviceId();
                        showSnackBar(
                            context: context, message: 'Device id $result');
                      },
                      boolean: true),
                  button(
                    text: 'Force crash',
                    onPressedReq: () async {
                      await FsAntiTheftPlugin.actionAntitheft(
                        actions: EnumActions.forceCrash,
                      );
                    },
                    boolean: true,
                  ),
                ],
              ),
            ),
          ),
        );
      }),
    );
  }

  Widget buttonMethod(
      {required String text,
      String? text2,
      Function()? onPressed1,
      Function()? onPressed2,
      bool boolean = false}) {
    return Padding(
      padding: const EdgeInsets.only(bottom: 8.0),
      child: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            if (onPressed1 != null)
              ElevatedButton(
                onPressed: onPressed1,
                child: Text('$text'),
              ),
            if (onPressed2 != null && text2 != null)
              ElevatedButton(
                onPressed: onPressed2,
                child: Text('$text2'),
              ),
          ],
        ),
      ),
    );
  }

  Widget button(
      {required String text,
      Function()? onPressedReq,
      Function()? onPressedCheck,
      bool boolean = false}) {
    return Padding(
      padding: const EdgeInsets.only(bottom: 8.0),
      child: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            if (onPressedCheck != null)
              ElevatedButton(
                onPressed: onPressedCheck,
                child: Text('$text check'),
              ),
            if (onPressedReq != null)
              ElevatedButton(
                onPressed: onPressedReq,
                child: Text('$text request'),
              ),
          ],
        ),
      ),
    );
  }

  void showSnackBar({
    required BuildContext context,
    required String message,
    Duration? duration,
  }) {
    ScaffoldMessenger.of(context)
        .clearSnackBars(); //clear any snack bars in queue and show current one
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(
        backgroundColor: Colors.blue,
        duration: duration ?? const Duration(seconds: 3),
        content: Text(
          message,
          style: const TextStyle(
            fontSize: 16,
            color: Colors.white,
          ),
        ),
      ),
    );
  }
}
0
likes
0
pub points
51%
popularity

Publisher

unverified uploader

Package do antitheft.

License

unknown (license)

Dependencies

android_alarm_manager_plus, flutter, permission_handler

More

Packages that depend on fs_anti_theft_flutter