screen_region_capture 0.0.1
screen_region_capture: ^0.0.1 copied to clipboard
Region screen capture plugin that outputs cropped native frames.
screen_region_capture #
Flutter plugin for capturing a rectangular screen region and outputting cropped native frames to an optional native frame sink.

MVP #
- Android:
MediaProjectionscreen authorization, CPU crop/scale/RGBA to I420, then nativeRegionFrameSinkoutput. - iOS: ReplayKit in-app capture authorization, CoreImage crop/scale to BGRA
CVPixelBuffer, then nativeScreenRegionFrameSinkoutput. - Dart only passes
Rect,fps,outputWidth, andoutputHeight; large pixel buffers stay native. - Events cover start, stop, permission denial, start failure, frame drop, and native errors.
const capture = ScreenRegionCapture();
await capture.start(
ScreenRegionCaptureConfig(
rect: rect,
fps: 15,
outputWidth: 960,
outputHeight: 540,
fit: ScreenRegionCaptureFit.aspectFit,
pixelRatio: View.of(context).devicePixelRatio,
androidNotification: const ScreenRegionCaptureAndroidNotification(
title: 'Gosh Live',
text: '正在共享局部屏幕',
icon: 'ic_stat_gosh_live',
),
),
);
await capture.updateRect(nextRect);
await capture.stop();
See example/ for a runnable app that captures a moving on-screen
region and displays the plugin's local preview texture.
Supported fit modes:
fill: stretch to the output size, may distort.aspectFit: keep aspect ratio and show the full region, with letterbox/pillarbox.aspectFill: keep aspect ratio and fill output, cropping edges.center: center at original captured pixel size.
androidNotification is optional and only used by Android. When omitted, the
plugin uses its default foreground-service notification. If icon is provided,
put a notification small icon with that resource name in the host app, for
example android/app/src/main/res/drawable/ic_stat_gosh_live.xml.