dropzone icon indicating copy to clipboard operation
dropzone copied to clipboard

DropZone does not work After Hot Restart

Open creativecreatorormaybenot opened this issue 3 years ago • 3 comments

When using a DropZone widget in a Flutter web app and using hot restart, the drop zone will stop working.

I investigated this and found out that the old listener is called instead of the new one after hot restart, i.e. the listener attached to the JS drop events survives the hot restart and no new listener is attached.

@Derrick56007 do you have an idea how to fix this?

hi @creativecreatorormaybenot

Could you post your code?

Also what was your expected vs actual result?

derrick56007 avatar Sep 21 '21 15:09 derrick56007

@Derrick56007

Color _color = Colors.white;

@override
Widget build(BuildContext context) {
  return DropZone(
    onDragEnter: () => setState(() => _color = Colors.green),
    onDragExit: () => setState(() => _color = Colors.white),
    child: ColoredBox(
      color: _color,
      child: const SizedBox.expand(),
    ),
  );
}

Replace this with the default Flutter template app.

Expected result:

  1. Run app.
  2. Drag file hover it over the area, then drag out again.
  3. → turns green, turns white.
  4. Hot restart app.
  5. Drag file hover it over the area, then drag out again.
  6. → turns green, turns white.

Actual result:

  1. Run app.
  2. Drag file hover it over the area, then drag out again.
  3. → turns green, turns white.
  4. Hot restart app.
  5. Drag file hover it over the area, then drag out again.
  6. nothing happens.

Facing the same issue here, even in release build of the application when the app is refreshed it throws "Render box not laid out"

RajSolai avatar Feb 07 '23 07:02 RajSolai