# widget_to_image **Repository Path**: jq_flutter/widget_to_image ## Basic Information - **Project Name**: widget_to_image - **Description**: 将flutter组件转换成图片 - **Primary Language**: Dart - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-12-04 - **Last Updated**: 2022-05-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # widget_to_image flutter 将组件转换成图片 ## 使用 1. 导包 ``` import 'package:widget_to_image/WidgetToImage.dart'; ``` 2. 使用 ``` GlobalKey globalKey = GlobalKey(); WidgetToImage( globalKeys: globalKey, alignment: Alignment.center, imageStr: "我是水印文本", imagePath: "images/shouji_bj2.png", stringSize: 16.0, stringColor: Colors.blue, // 需要保存下来的组件 可以是任意组件,child 为空时 imagePath 不可为空 child: QrImage( data: "${logic.myInvitationsEntity?.data?.shareUrl ?? ''}", version: QrVersions.auto, size: 185, ), ), // 拿到widget转换后的图片 // 返回 getByte64,getFile,getUint8List 三种 Future file = getWidgetToImage.getInstance(globalKey1).getFile(); file.then((value) => { print(value) }); ```