access_photo 0.0.1+1 copy "access_photo: ^0.0.1+1" to clipboard
access_photo: ^0.0.1+1 copied to clipboard

Image and video from provided temp path get saved to device(Photos).

all code is from #

https://github.com/CarnegieTechnologies/gallery_saver

access_photo for Flutter ios #

Saves images and videos from temporary file to album. Both images and videos will be visible in iOS Photos.

Installation #

First, add access_photo as a dependency in your pubspec.yaml file.

iOS #

Add the following keys to your Info.plist file, located in <project root>/ios/Runner/Info.plist:

  • NSPhotoLibraryUsageDescription - describe why your app needs permission for the photo library. This is called Privacy - Photo Library Usage Description in the visual editor.

Example #

import 'package:flutter/material.dart';
import 'package:image_saver/image_saver.dart';
import 'package:dio/dio.dart';
import 'package:path_provider/path_provider.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Save image to gallery',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  GlobalKey _globalKey = GlobalKey();

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Save image to gallery"),
      ),
      body: Center(
        child: Column(
          children: <Widget>[
            Container(
              padding: EdgeInsets.only(top: 15),
              child: RaisedButton(
                onPressed: _saveGif,
                child: Text("Save Gif to gallery"),
              ),
              width: 200,
              height: 44,
            ),
          ],
        ),
      ),
    );
  }

  _saveGif() async {
    var appDocDir = await getTemporaryDirectory();
    String savePath = appDocDir.path + "/temp.gif";
    String fileUrl = "https://hyjdoc.oss-cn-beijing.aliyuncs.com/hyj-doc-flutter-demo-run.gif";
    await Dio().download(fileUrl, savePath);
    final result = await ImageSaver.saveImage(savePath);
    print(result);
  }
}
0
likes
30
pub points
0%
popularity

Publisher

unverified uploader

Image and video from provided temp path get saved to device(Photos).

Repository (GitHub)
View/report issues

License

Apache-2.0 (LICENSE)

Dependencies

flutter, path

More

Packages that depend on access_photo