MixinNetwork / MixinNetwork/flutter-plugins

Listener will be binded twice while its parent rebuild

Open
#407 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
512
Forks
292
Avg merge
15h 8m
Merged PRs (30d)
7

Description

class FileDropBox extends StatelessWidget {
  FileDropBox({super.key});

  final controller = Get.put(FileDropController());
  @override
  Widget build(BuildContext context) {
    return DropTarget(
      onDragDone: (details) {
        final paths = details.files.map((file) => file.path).toList();
        debugPrint("onDragDone!!!");
        controller.onFilesDropped(paths);
      },
      child: const SizedBox.expand(),
    );
  }
}

For example, when the stateless widget FileDropBox rebuild, DropTarget will add a new onDragDone listener.
Which Means when I drop file to this widget, it will run onDragDone twice.

When FileDropBox rebuild again, onDragDone will run for three times.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the FileDropBox example and inspect DropTarget's listener lifecycle, especially how its onDragDone callback is registered when the parent rebuilds. Reproduce the example across rebuilds and verify that dropping a file invokes the callback only once, then check the relevant plugin tests if available.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
desktop-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.