webfiledrop 1.0.0 copy "webfiledrop: ^1.0.0" to clipboard
webfiledrop: ^1.0.0 copied to clipboard

Platformweb

Easy to use file drop plugin for flutter web.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:webfiledrop/webfiledrop.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Uint8List? selectedFile;

  @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(
            children: [
              selectedFile != null
                  ? Image.memory(selectedFile!)
                  : const SizedBox.shrink(),
              const SizedBox(
                height: 20,
              ),
              Container(
                decoration:
                    BoxDecoration(border: Border.all(color: Colors.blueAccent)),
                child: WebFileDropArea(onFileDrop: (file) async {
                  selectedFile = await WebFileDrop.htmlFileToMemoryFile(file);
                  setState(() {});
                }),
              )
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
130
points
29
downloads

Publisher

unverified uploader

Weekly Downloads

Easy to use file drop plugin for flutter web.

Documentation

API reference

License

GPL-3.0 (license)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface, universal_html

More

Packages that depend on webfiledrop

Packages that implement webfiledrop