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

Screen Recorder Callback plugin for detecting screen recording on Android and iOS.

example/lib/main.dart

import 'dart:async';

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

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

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

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

class _MyAppState extends State<MyApp> {
  bool isRecording = false;
  final ScreenRecorderCallback _screenRecorderApi = ScreenRecorderCallback();
  StreamSubscription<bool>? _recordingSubscription;

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

  // Initializes the screen recording callback.
  Future<void> initScreenRecordingCallback() async {
    try {
      _recordingSubscription =
          _screenRecorderApi.onScreenRecordingChangeStream.listen((recording) {
        setState(() {
          isRecording = recording;
        });
      });

      await _screenRecorderApi.startListening();
    } catch (e) {
      setState(() {
        isRecording = false; // Show "Not Recording" on error
      });
    }
  }

  @override
  void dispose() {
    _screenRecorderApi.stopListening();
    _recordingSubscription?.cancel();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        backgroundColor: isRecording ? Colors.red : Colors.white,
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Icon(
                isRecording ? Icons.videocam : Icons.videocam_off,
                size: 80,
                color: isRecording ? Colors.white : Colors.black54,
              ),
              const SizedBox(height: 20),
              Text(
                isRecording ? 'Recording...' : 'Not Recording',
                style: TextStyle(
                  color: isRecording ? Colors.white : Colors.black54,
                  fontSize: 24,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
6
likes
140
points
36
downloads

Publisher

verified publishertajaouart.com

Weekly Downloads

Screen Recorder Callback plugin for detecting screen recording on Android and iOS.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on screen_recorder_callback