FLUTTER ECOSYSTEM

AWarmHug/widget_screenshot

小部件的截图,支持像 ListView 这样的长截图

widget_screenshot 项目封面
Stars
3
Forks
8
最近推送(UTC)
2023年11月10日
项目状态
未归档
bingo GitHub avatar
GITHUB User

bingo ↗

我们不是代码的搬运工,而是代码的学习者。

语言DartKotlinSwiftRubyObjective-C

技术话题

此仓库发布的插件

使用的依赖

依赖清单 4 项
  • flutter{"sdk":"flutter"}
  • plugin_platform_interface^2.0.2
  • flutter_test开发依赖{"sdk":"flutter"}
  • flutter_lints开发依赖^2.0.0

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

展开 / 收起项目 README

widget_screenshot

Widget截屏,支持长截图,如:ListView

Screenshot for widget,support long screenshot like ListView,

Support

  • backgroundColor
  • format (png, jpeg)
  • quality (0~100)
  • extraImage (like header, footer or watermark)

Usage

dependencies:
  widget_screenshot:x.y.z
// Like RepaintBoundary
WidgetShot(
        key: _shotKey,
        child: ListView.separated(
            controller: _scrollController,
            itemBuilder: (context, index) {
              return Container(
                color: Color.fromARGB(
                    Random().nextInt(255), Random().nextInt(255), Random().nextInt(255), Random().nextInt(255)),
                height: 160,
                child: Center(
                  child: Text(
                    "测试文案测试文案测试文案测试文案 ${index}",
                    style: const TextStyle(fontSize: 32),
                  ),
                ),
              );
            },
            separatorBuilder: (context, index) {
              return const Divider(
                height: 1,
                color: Colors.grey,
              );
            },
            itemCount: 30),
      )
WidgetShotRenderRepaintBoundary repaintBoundary =
    _shotKey.currentContext!.findRenderObject() as WidgetShotRenderRepaintBoundary;
//
var resultImage = await repaintBoundary.screenshot(scrollController: _scrollController,pixelRatio: 1);

Display

https://raw.githubusercontent.com/AWarmHug/widget_screenshot/main/display/shot.webp shoting-> https://raw.githubusercontent.com/AWarmHug/widget_screenshot/main/display/shoting.gif result-> https://raw.githubusercontent.com/AWarmHug/widget_screenshot/main/display/shoted.webp