deakjahn / flutter_dropzone

A drag-and-drop Flutter plugin (Web). Only web and only from outside into Flutter.
https://pub.dev/packages/flutter_dropzone
85 stars 36 forks source link

Proper example when there're other widgets in the `Stack` with `DropzoneView` #71

Open coder-with-a-bushido opened 8 months ago

coder-with-a-bushido commented 8 months ago

According to the example in the README, the right way to use the widget is -

Stack(
  children: [
    DropzoneView(...),
    Center(child: Text('Drop files here')),
  ],
)

In many cases, DropzoneView is used in Stack with other widgets on top of it but there no example for it. Something like -

Stack(
  children: [
    DropzoneView(...),
    // Other Widgets
    Center(child: Text('Drop files here')),
  ],
)

But when there's SelectionArea in the widget above it, for some reason DropzoneView doesn't seem to work above it.

coder-with-a-bushido commented 8 months ago

I solved this issue by keeping the DropzoneView on top of the rest of widgets and wrapping it with IgnorePointer. So, we could add an example in the README like -

Stack(
  children: [
    // Other Widgets
    IgnorePointer(
        child: DropzoneView(...),
    ),
    if(isHovered)
        Center(child: Text('Drop files here')),
  ],
)

Use the onHover, onDrop and onLeave and set the state for the variable isHovered

DavidOrakpo commented 4 months ago

You sir, are a genius. Thanks from Nigeria!