webfiledrop 1.0.0
webfiledrop: ^1.0.0 copied to clipboard
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(() {});
}),
)
],
),
),
),
);
}
}