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

PlatformAndroid

Plugin disable screenshot for android.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:flutter_screenshot_disable/flutter_screenshot_disable.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) => const MaterialApp(home: ExamplePage());
}

class ExamplePage extends StatefulWidget {
  const ExamplePage({Key? key}) : super(key: key);

  @override
  State<ExamplePage> createState() => _ExamplePageState();
}

class _ExamplePageState extends State<ExamplePage> {
  bool _disableScreenshot = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Center(child: Text('Flutter screenshot disable')),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              _disableScreenshot
                  ? const Text(
                      'Screenshot disabled',
                      style: TextStyle(
                        color: Colors.red,
                        fontSize: 20,
                        fontWeight: FontWeight.w500,
                      ),
                    )
                  : const Text(
                      'Screenshot included',
                      style: TextStyle(
                        color: Colors.green,
                        fontSize: 20,
                        fontWeight: FontWeight.w500,
                      ),
                    ),
              const Icon(Icons.screenshot_outlined, size: 50),
            ],
          ),
          const SizedBox(height: 50),
          ElevatedButton(
              onPressed: () async {
                bool flag = !_disableScreenshot;
                // Disable or allow screenshots
                await FlutterScreenshotDisable.disableScreenshot(flag);
                setState(() {
                  _disableScreenshot = flag;
                });
              },
              child: Text(_disableScreenshot ? "Allow screenshot" : "Disable screenshot")),
        ],
      ),
    );
  }
}
3
likes
120
pub points
49%
popularity

Publisher

unverified uploader

Plugin disable screenshot for android.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_screenshot_disable