image_save 1.1.3+1 copy "image_save: ^1.1.3+1" to clipboard
image_save: ^1.1.3+1 copied to clipboard

outdated

You could use this package to save image to album, support Android and iOS. It is ability to get storage path.

example/lib/main.dart

import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:dio/dio.dart';
import 'package:flutter/services.dart';
import 'package:image_save/image_save.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _imagePath = '';

  @override
  void initState() {
    super.initState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> _saveImage() async {
    // Platform messages may fail, so we use a try/catch PlatformException.
    String imagePath = "";
    try {
      Response<List<int>> res = await Dio().get<List<int>>(
          "http://img.youai123.com/1507615921-5474.gif",
          options: Options(responseType: ResponseType.bytes));
      imagePath =
          await ImageSave.saveImage("gif", Uint8List.fromList(res.data));
    } on PlatformException {
      imagePath = '未能保存成功';
    }
    setState(() {
      _imagePath = imagePath;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
            	Image.network('http://img.youai123.com/1507615921-5474.gif'),
              RaisedButton(
                onPressed: _saveImage,
                child: Text("点击保存"),
              ),
              Text("保存到了$_imagePath")
            ],
          ),
        ),
      ),
    );
  }
}
29
likes
40
points
224
downloads

Publisher

unverified uploader

Weekly Downloads

You could use this package to save image to album, support Android and iOS. It is ability to get storage path.

Repository (GitHub)

License

MIT (license)

Dependencies

flutter

More

Packages that depend on image_save