将此png保存到颤振中的手机图库

时间:2021-04-03 10:26:03

标签: flutter dart flutter-dependencies flutter-test

 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 图像,但下一步是将其保存到手机图库。 我尝试了许多依赖项来将图像保存到图库,但不幸的是它们都不适合我。 我想要一个按钮在屏幕上的任何位置,并按下该按钮将图像保存在画廊中。

0 个答案:

没有答案