首页 > 解决方案 > 将此png保存到颤振的电话画廊

问题描述

 void _show(PictureDetails picture, BuildContext context) {
setState(() {
  _finished = true;
});

Navigator.of(context)
    .push(new MaterialPageRoute(builder: (BuildContext context) {
  return new Scaffold(
    appBar: new AppBar(
      title: const Text('your image'),
    ),
    body: new Container(
        alignment: Alignment.center,
        child: new FutureBuilder<Uint8List>(
          future: picture.toPNG(),
          builder:
              (BuildContext context, AsyncSnapshot<Uint8List> snapshot) {
            switch (snapshot.connectionState) {
              case ConnectionState.done:
                if (snapshot.hasError) {
                  return new Text('Error: ${snapshot.error}');
                } else {


                  return Image.memory(snapshot.data!);
                }
            
              default:
                return new Container(
                    child: new FractionallySizedBox(
                      widthFactor: 0.1,
                      child: new AspectRatio(
                          aspectRatio: 1.0,
                          child: new CircularProgressIndicator()),
                      alignment: Alignment.center,
                    ));
            }
          },
        )),
  );
}));

} }

此类在屏幕上显示 png 图像,但下一步是将其保存到手机图库。我尝试了许多依赖项将图像保存到图库,但不幸的是它们都不适合我。我想在屏幕上的任何地方都有一个按钮,按下该按钮,图像就会保存在画廊中。

标签: flutterdartflutter-dependenciesflutter-test

解决方案


推荐阅读