image_save 3.0.0 copy "image_save: ^3.0.0" to clipboard
image_save: ^3.0.0 copied to clipboard

outdated

You could use this package to save image to album or sandbox, support Android and iOS.

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 _result = "";
  Uint8List _data;

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

  void getData() async {
    Response<List<int>> res = await Dio().get<List<int>>(
        "http://img.youai123.com/1507615921-5474.gif",
        options: Options(responseType: ResponseType.bytes));
    _data = Uint8List.fromList(res.data);
  }

  Future<void> _saveImage() async {
    bool success = false;
    try {
      success = await ImageSave.saveImage(_data, "gif", albumName: "demo");
    } on PlatformException catch (e, s) {
      print(e);
      print(s);
    }
    setState(() {
      _result = success ? "Save to album success" : "Save to album failed";
    });
  }

  Future<void> _saveImageToSandBox() async {
    bool success = false;
    try {
      success = await ImageSave.saveImageToSandbox(_data, "demo.gif");
    } on PlatformException catch (e, s) {
      print(e);
      print(s);
    }
    setState(() {
      _result = success ? "Save to sandbox success" : "Save to sandbox failed";
    });
  }

  @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("Click to save to album"),
              ),
              RaisedButton(
                onPressed: _saveImageToSandBox,
                child: Text("Click to save to sandbox"),
              ),
              Text(_result)
            ],
          ),
        ),
      ),
    );
  }
}
28
likes
0
pub points
88%
popularity

Publisher

unverified uploader

You could use this package to save image to album or sandbox, support Android and iOS.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on image_save