ff_native_screenshot 1.0.0 copy "ff_native_screenshot: ^1.0.0" to clipboard
ff_native_screenshot: ^1.0.0 copied to clipboard

A Flutter plugin to take or listen screenshot(support Platform Views) for Android and iOS with native code.

ff_native_screenshot #

A Flutter plugin to take or listen screenshot(support Platform Views) for Android and iOS with native code.

It's a workaround for the issue RepaintBoundary can't take screenshot of Platform Views .

pub package GitHub stars GitHub forks GitHub license GitHub issues flutter-candies

Usage #

dependencies:
  ff_native_screenshot: any
  # only for android
  permission_handler: any

Take Screenshot #

Uint8List? data = await FfNativeScreenshot().takeScreenshot();

Listen Screenshot #


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

  Future<void> init() async {
    if (Platform.isAndroid) {
      await Permission.storage.request();
    }
    FfNativeScreenshot().setup(ScreenshotFlutterApiImplements(context));
    await FfNativeScreenshot().startListeningScreenshot();

    if (mounted) {
      setState(() {});
    }
  }

  @override
  void dispose() {
    FfNativeScreenshot().stopListeningScreenshot();
    super.dispose();
  }

  bool? listening;
  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    super.didChangeAppLifecycleState(state);
    switch (state) {
      case AppLifecycleState.resumed:
        if (listening == true && !FfNativeScreenshot().listening) {
          FfNativeScreenshot().startListeningScreenshot();
        }
        break;
      case AppLifecycleState.paused:
        listening = FfNativeScreenshot().listening;
        if (listening == true) {
          FfNativeScreenshot().stopListeningScreenshot();
        }

        break;
      default:
    }
  }

  class ScreenshotFlutterApiImplements extends ScreenshotFlutterApi {
    ScreenshotFlutterApiImplements();
    @override
    Future<void> onTakeScreenshot(Uint8List? data) async {
     // if it has something error
     // you can call takeScreenshot 
     data ??= await FfNativeScreenshot().takeScreenshot();
    }
  }

11
likes
130
pub points
80%
popularity

Publisher

verified publisherfluttercandies.com

A Flutter plugin to take or listen screenshot(support Platform Views) for Android and iOS with native code.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on ff_native_screenshot