image_downloader 0.10.0 copy "image_downloader: ^0.10.0" to clipboard
image_downloader: ^0.10.0 copied to clipboard

outdated

Flutter plugin that downloads images on the Internet and saves them on device.

example/lib/main.dart

import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_downloader/image_downloader.dart';

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

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

class _MyAppState extends State<MyApp> {
  bool _isSuccess = false;
  String _message = "";

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Text('Running on: $_isSuccess\n$_message'),
              RaisedButton(
                onPressed: () {
                  _downloadImage();
                },
                child: Text("save image."),
              ),
            ],
          ),
        ),
      ),
    );
  }

  Future<void> _downloadImage() async {
    bool isSuccess;
    try {
      isSuccess = await ImageDownloader.downloadImage("https://raw.githubusercontent.com/wiki/ko2ic/image_downloader/images/flutter.jpg");
    } on PlatformException catch (_) {
      isSuccess = false;
    }

    if (!mounted) return;

    setState(() {
      _isSuccess = isSuccess;
      var location = Platform.isAndroid ? "Download Directory" : "Photo Library";
      _message = 'Image saved in $location';
    });
  }
}
259
likes
0
pub points
95%
popularity

Publisher

unverified uploader

Flutter plugin that downloads images on the Internet and saves them on device.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on image_downloader