基础组件库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

60 lines
2.0 KiB

  1. import 'dart:typed_data';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/rendering.dart';
  4. import 'package:zhiying_base_widget/template/goods_share_template/goods_share_template.dart';
  5. import 'package:image_gallery_saver/image_gallery_saver.dart';
  6. class FavoritePage extends StatefulWidget {
  7. @override
  8. _FavoritePageState createState() => _FavoritePageState();
  9. }
  10. class _FavoritePageState extends State<FavoritePage> {
  11. GlobalKey globalKey = GlobalKey();
  12. @override
  13. Widget build(BuildContext context) {
  14. return Scaffold(
  15. appBar: AppBar(
  16. title: Text('收藏夹'),
  17. ),
  18. body: Column(
  19. children: <Widget>[
  20. Container(
  21. width: 100,
  22. height: 200,
  23. child: Transform.scale(
  24. scale: 0.2, child: GoodsShareTemplate(key: globalKey)),
  25. ),
  26. FlatButton(
  27. child: Icon(Icons.add),
  28. onPressed: () async {
  29. BuildContext buildContext = globalKey.currentContext;
  30. if (null != buildContext) {
  31. RenderRepaintBoundary boundary =
  32. buildContext.findRenderObject();
  33. var image = await boundary.toImage();
  34. ByteData byteData =
  35. await image.toByteData(format: ui.ImageByteFormat.png);
  36. // final result = await ImageGallerySaver.saveImage(
  37. // byteData.buffer.asUint8List());
  38. // var response = await Dio().get(
  39. // "https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=a62e824376d98d1069d40a31113eb807/838ba61ea8d3fd1fc9c7b6853a4e251f94ca5f46.jpg",
  40. // options: Options(responseType: ResponseType.bytes));
  41. // final result = await ImageGallerySaver.saveImage(
  42. // Uint8List.fromList(image),
  43. // quality: 60,
  44. // name: "hello");
  45. // print(result);
  46. }
  47. },
  48. )
  49. ],
  50. ),
  51. );
  52. }
  53. }