|
- import 'dart:typed_data';
-
- import 'package:flutter/material.dart';
- import 'package:flutter/rendering.dart';
- import 'package:zhiying_base_widget/template/goods_share_template/goods_share_template.dart';
-
- import 'package:image_gallery_saver/image_gallery_saver.dart';
-
- class FavoritePage extends StatefulWidget {
- @override
- _FavoritePageState createState() => _FavoritePageState();
- }
-
- class _FavoritePageState extends State<FavoritePage> {
- GlobalKey globalKey = GlobalKey();
-
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text('收藏夹'),
- ),
- body: Column(
- children: <Widget>[
- Container(
- width: 100,
- height: 200,
- child: Transform.scale(
- scale: 0.2, child: GoodsShareTemplate(key: globalKey)),
- ),
- FlatButton(
- child: Icon(Icons.add),
- onPressed: () async {
- BuildContext buildContext = globalKey.currentContext;
-
- if (null != buildContext) {
- RenderRepaintBoundary boundary =
- buildContext.findRenderObject();
- var image = await boundary.toImage();
- ByteData byteData =
- await image.toByteData(format: ui.ImageByteFormat.png);
- // final result = await ImageGallerySaver.saveImage(
- // byteData.buffer.asUint8List());
- // var response = await Dio().get(
- // "https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=a62e824376d98d1069d40a31113eb807/838ba61ea8d3fd1fc9c7b6853a4e251f94ca5f46.jpg",
- // options: Options(responseType: ResponseType.bytes));
- // final result = await ImageGallerySaver.saveImage(
- // Uint8List.fromList(image),
- // quality: 60,
- // name: "hello");
- // print(result);
- }
- },
- )
- ],
- ),
- );
- }
- }
|