paused_secret 0.0.1 copy "paused_secret: ^0.0.1" to clipboard
paused_secret: ^0.0.1 copied to clipboard

paused secret.

example/lib/main.dart

import 'dart:async';
import 'dart:io';

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

import 'package:paused_secret/paused_secret.dart';
import 'package:permission_handler/permission_handler.dart';

void main() {
  runApp(const MaterialApp(home: MyApp()));
}

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

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

class _MyAppState extends State<MyApp> {
  final _pausedSecretPlugin = PausedSecret();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          title: const Text('Plugin example app'),
          centerTitle: true,
          actions: [
            IconButton(
              onPressed: () {
                openAppSettings();
              },
              icon: const Icon(Icons.developer_board_rounded),
            )
          ]),
      body: ListView(
        physics: const NeverScrollableScrollPhysics(),
        children: [
          ...ListTile.divideTiles(context: context, tiles: _b(context))
        ],
      ),
    );
  }

  bool disableScreenshot = false;
  bool pausedSecret = false;
  bool pausedSecretGlobal = false;
  StreamSubscription<dynamic>? screenshotListener;
  List<bool> overlay = [false, false, false];

  List<Widget> _b(BuildContext context) {
    return [
      const SizedBox(),
      ListTile(
        title: const Text('Running on PlatformName: '),
        trailing: FutureBuilder<String?>(
          future: IsDebug().getHostPlatformName(),
          builder: (c, s) => Text('${s.data}'),
        ),
      ),
      ListTile(
        title: const Text('Running on PlatformVersion: '),
        trailing: FutureBuilder<String?>(
          future: IsDebug().getHostPlatformVersion(),
          builder: (c, s) => Text('${s.data}'),
        ),
      ),
      CheckboxListTile(
        title: const Text("disableScreenshot"),
        subtitle: const Text(
          "only support android",
        ),
        value: disableScreenshot,
        onChanged: (b) {
          if (!Platform.isAndroid) {
            ScaffoldMessenger.of(context).showSnackBar(
              const SnackBar(content: Text("only support android")),
            );
            return;
          }
          disableScreenshot = b == true;
          setState(() {});
          _pausedSecretPlugin.disableScreenshot(disableScreenshot);
        },
      ),
      CheckboxListTile(
        title: const Text("pausedSecret"),
        subtitle: const Text("support android13+ and ios"),
        value: pausedSecret,
        onChanged: (b) {
          pausedSecret = b == true;
          setState(() {});
          _pausedSecretPlugin.pausedSecret(pausedSecret);
        },
      ),
      CheckboxListTile(
        title: const Text("pausedSecretGlobal"),
        subtitle: const Text("Warning: android cannot screenshot"),
        value: pausedSecretGlobal,
        onChanged: (b) {
          pausedSecretGlobal = b == true;
          setState(() {});
          _pausedSecretPlugin.pausedSecret(pausedSecretGlobal);
          _pausedSecretPlugin.disableScreenshot(pausedSecretGlobal);
        },
      ),
      CheckboxListTile(
        title: const Text("screenshotListener"),
        subtitle: const Text(
          "support android14+ and ios\n"
          "below android14 requires permission",
        ),
        value: screenshotListener != null,
        onChanged: (b) {
          if (b == true) {
            if (Platform.isAndroid) {}
            screenshotListener = _pausedSecretPlugin.onScreenshot().listen(
              (event) {
                ScaffoldMessenger.of(context).showSnackBar(
                  const SnackBar(content: Text("Screenshot running")),
                );
              },
            );
          } else {
            screenshotListener?.cancel();
            screenshotListener = null;
          }
          setState(() {});
        },
      ),
      ..._bOverlay(context),
      const Padding(
        padding: EdgeInsets.all(16.0),
        child: Center(child: CircularProgressIndicator()),
      ),
      const SizedBox(),
    ];
  }

  List<Widget> _bOverlay(BuildContext context) {
    return [
      Container(
        alignment: Alignment.center,
        padding: const EdgeInsets.all(8),
        child: const Text("SecretOverlayView"),
      ),
      CheckboxListTile(
        title: const Text("pausedSecretOverlay"),
        subtitle: const Text(
          "some android device no support\n"
          "they onPaused cannot draw screen view",
        ),
        value: overlay[0],
        onChanged: (b) {
          overlay[0] = b == true;
          if (overlay[0]) {
            PausedSecret.addPausedSecretOverlay(context);
          } else {
            if (Platform.isAndroid) {
              _pausedSecretPlugin.pausedSecret(false);
            }
            PausedSecret.removePausedSecretOverlay();
          }
          setState(() {});
        },
      ),
      CheckboxListTile(
        title: const Text("resumedSecretOverlay"),
        value: overlay[1],
        onChanged: (b) {
          overlay[1] = b == true;
          setState(() {});
          if (overlay[1]) {
            PausedSecret.addResumedSecretOverlay(context);
          } else {
            PausedSecret.removeResumedSecretOverlay();
          }
        },
      ),
      CheckboxListTile(
        title: const Text("watermarkOverlay"),
        value: overlay[2],
        onChanged: (b) {
          overlay[2] = b == true;
          setState(() {});
          if (overlay[2]) {
            PausedSecret.addWatermarkOverlay(context, "jawa0919@163.com");
          } else {
            PausedSecret.removeWatermarkOverlay();
          }
        },
      ),
    ];
  }
}
2
likes
130
points
22
downloads
screenshot

Publisher

unverified uploader

Weekly Downloads

paused secret.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on paused_secret