image_downloader_web 2.0.6 copy "image_downloader_web: ^2.0.6" to clipboard
image_downloader_web: ^2.0.6 copied to clipboard

Platformweb

A Flutter plugin for downloading images from URL to user's device. This plugin only works for Flutter web.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:image_downloader_web/image_downloader_web.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Web image downloader example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const ImageDownloaderExample(),
    );
  }
}

class ImageDownloaderExample extends StatefulWidget {
  const ImageDownloaderExample({Key? key}) : super(key: key);

  @override
  _ImageDownloaderExampleState createState() => _ImageDownloaderExampleState();
}

class _ImageDownloaderExampleState extends State<ImageDownloaderExample> {
  bool downloading = false;

  Future<void> _downloadImage() async {
    setState(() {
      downloading = true;
    });
    const _url = "https://picsum.photos/200";
    await WebImageDownloader.downloadImageFromWeb(
      _url,
      name: 'image01',
      imageType: ImageType.png,
    );
    setState(() {
      downloading = false;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Web image downloader example"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            if (downloading)
              const CircularProgressIndicator()
            else
              MaterialButton(
                onPressed: _downloadImage,
                child: const Text(
                  "Download",
                  style: TextStyle(
                    color: Colors.white,
                  ),
                ),
                color: Colors.blue,
              )
          ],
        ),
      ),
    );
  }
}
45
likes
150
points
13.5k
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for downloading images from URL to user's device. This plugin only works for Flutter web.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_web_plugins, http, universal_html

More

Packages that depend on image_downloader_web