Skip to content

pd17481/flutter_windows_native_drop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flutter_windows_native_drop

Windows-only Flutter plugin that handles native OLE drag-and-drop and clipboard paste, including the TYMED_ISTORAGE transfer type used by Outlook Classic when email items are dragged directly from the folder view.

Why?

Most existing Flutter drag-and-drop plugins (super_drag_and_drop, desktop_drop, etc.) work great for normal files but silently drop Outlook Classic email items because Outlook delivers them as an OLE compound document via TYMED_ISTORAGE — a transfer mode those plugins don't flatten.

This plugin handles all virtual-file transfer modes that real-world Windows apps use:

Mode Used by
CF_HDROP Explorer, generic file drops
TYMED_HGLOBAL Many in-memory drag sources
TYMED_ISTREAM Outlook attachments, browser downloads
TYMED_ISTORAGE Outlook Classic email items (.msg)

The same OLE pipeline is also exposed via getClipboardFiles() so Ctrl+V of an Outlook email Just Works.

How it works

The plugin registers an IDropTarget on the Flutter view HWND via RegisterDragDrop. This means:

  • It is incompatible with super_drag_and_drop / desktop_drop when both try to own the same window's drop target. Use one or the other — not both.
  • Drop events stream back to Dart via an EventChannel.
  • A handler stack lets modal dialogs override the page-level handler.

Usage

1. Add to pubspec.yaml

dependencies:
  flutter_windows_native_drop:
    git:
      url: git@github.com:pd17481/flutter_windows_native_drop.git
      ref: v0.1.0

2. Register a drop handler

import 'package:flutter_windows_native_drop/flutter_windows_native_drop.dart';

@override
void initState() {
  super.initState();
  WindowsNativeDrop.pushHandler(
    onDrop: (files) {
      for (final f in files) {
        debugPrint('Got ${f.name}: ${f.bytes.length} bytes');
      }
    },
    onDragEnter: () => setState(() => _hover = true),
    onDragLeave: () => setState(() => _hover = false),
  );
}

@override
void dispose() {
  WindowsNativeDrop.popHandler();
  super.dispose();
}

The handler stack means a dialog can push its own handler in initState and pop it in dispose; the underlying page handler resumes automatically.

3. Clipboard paste

final files = await WindowsNativeDrop.getClipboardFiles();

Returns whatever is on the clipboard in the same format as drop events. Useful for Ctrl+V of Outlook email items.

Platform support

Platform Status
Windows Supported
Other All API calls are safe no-ops (return false / empty lists)

WindowsNativeDrop.isSupported returns true only on Windows desktop.

License

MIT

About

Windows-only Flutter plugin that handles native OLE drag-and-drop and clipboard paste, including the `TYMED_ISTORAGE` transfer type used by Outlook Classic when email items are dragged directly from the folder view.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors