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