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

PlatformmacOS

A Flutter plugin for screen sharing on macOS using ScreenCaptureKit.

example/lib/main.dart

import 'dart:typed_data';

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

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

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

  @override
  State<ScreenCapture> createState() => _ScreenCaptureState();
}

class _ScreenCaptureState extends State<ScreenCapture> {
  ScreenShareController screenSharer = ScreenShareController();

  void startCapture() async {
    await screenSharer.startCaptureWithDialog(
      context: context,
      onData: (Uint8List frame) {
        debugPrint('Frame received: ${frame.length} bytes');
      },
    );
    setState(() {});
  }

  void stopCapture() async {
    await screenSharer.stopCapture();

    setState(() {});
  }

  @override
  void dispose() {
    screenSharer.stopCapture();

    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return ValueListenableBuilder(
      valueListenable: screenSharer.isSharing,
      builder: (context, isSharing, child) {
        return Column(
          children: [
            if (isSharing)
              Expanded(
                child: Center(child: ScreenShareView(controller: screenSharer)),
              ),
            Padding(
              padding: const EdgeInsets.all(16.0),
              child: ElevatedButton(
                onPressed: !isSharing ? startCapture : stopCapture,
                child: Text(!isSharing ? 'Start Capture' : 'Stop Capture'),
              ),
            ),
          ],
        );
      },
    );
  }
}
10
likes
150
points
20
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for screen sharing on macOS using ScreenCaptureKit.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_screen_share