Giter VIP home page Giter VIP logo

flutter_forbidshot's Introduction

flutter_forbidshot

pub package A Flutter plugin to prevent capture and record screen on ios and android.

Setup

flutter_forbidshot: 0.0.2

Usage

1. IOS API

  1. Get the current recording screen state (获取到当前是否在录屏)
bool isCapture = await FlutterForbidshot.iosIsCaptured;
  1. Screen recording status changes will call back (录屏状态变化会回调)
StreamSubscription<void> subscription = FlutterForbidshot.iosShotChange.listen((event) {});

2. Android API

  1. Turn on the forbid screen (开启禁止录屏)
FlutterForbidshot.setAndroidForbidOn();
  1. Turn off the forbid screen (取消禁止录屏)
FlutterForbidshot.setAndroidForbidOff();

Example

class _MyAppState extends State<MyApp> {
  bool isCaptured = false;
  StreamSubscription<void> subscription;

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

  init() async {
    bool isCapture = await FlutterForbidshot.iosIsCaptured;
    setState(() {
      isCaptured = isCapture;
    });
    subscription = FlutterForbidshot.iosShotChange.listen((event) {
      setState(() {
        isCaptured = !isCaptured;
      });
    });

  }

  @override
  void dispose() {
    super.dispose();
    subscription?.cancel();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('flutter_borbidshot example app'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              Text('IOS:isCaptured:${isCaptured}'),
              RaisedButton(
                child: Text('Android forbidshot on'),
                onPressed: () {
                  FlutterForbidshot.setAndroidForbidOn();
                },
              ),
              RaisedButton(
                child: Text('Android forbidshot off'),
                onPressed: () {
                  FlutterForbidshot.setAndroidForbidOff();
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}

注意⚠️

1.使用ios api可以在应用内做监听后暂停视频播放;

2.测试android api在小米手机只能拦截截屏,在三星手机可以拦截截屏,录屏后视频内容变成黑色;

flutter_forbidshot's People

Contributors

chartype avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.