fit_system_screenshot 1.0.6 copy "fit_system_screenshot: ^1.0.6" to clipboard
fit_system_screenshot: ^1.0.6 copied to clipboard

outdated

让Flutter应用适配安卓系统的长截图

fit_system_screenshot #

让Flutter应用适配安卓系统的长截图

安装与卸载 #

1、初始化截屏库

fitSystemScreenshot.init()

2、卸载截屏库

fitSystemScreenshot.release()

基础使用(参考Demo中的Basic Usage) #

1、在需要支持长截屏的页面设置 scrollController ,保证系统在截屏时自动滚动内容

  fitSystemScreenshot.attach(scrollController);

2、指定滚动区域

  fitSystemScreenshot.updateScrollArea(render.rect);

3、当支持长截屏的页面退出时,释放对象

  fitSystemScreenshot.detach();

高级使用(参考Demo中的 FitSystemScreenshotWidget Usage) #

  @override
  Widget build(BuildContext context) {
    //...
    return Scaffold(
      appBar: AppBar(title: Text('FitSystemScreenshotWidget Usage')),
      //1、使用FitSystemScreenshotWidget包裹滚动控件
      body: FitSystemScreenshotWidget(
        key: screenShotKey,
        controller: scrollController,
        child: SingleChildScrollView(
          controller: scrollController,
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: children,
          ),
        ),
      ),
    );
  }
  
  @override
  void onLifecycleEvent(LifecycleEvent event) {
    if (event == LifecycleEvent.active) { //2、当前页面可见时调用
      //等待Element树构建
      Future.delayed(Duration.zero, () {
        FitSystemScreenshotWidgetState? currentState =
            screenShotKey.currentState;
        if (currentState == null) return;
        currentState.attach();
      });
    } else if (event == LifecycleEvent.inactive) { //3、当前页面不可见时调用
      FitSystemScreenshotWidgetState? currentState = screenShotKey.currentState;
      if (currentState == null) return;
      currentState.detach();
    }
  }