Skip to content

Removing a draggable from the widget tree while it's being dragged leaves the feedback in the overlay. #6151

Closed

Description

@apwilson
// Copyright 2016 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:flutter/widgets.dart';

Future main() async {
  runApp(
    new Overlay(
      initialEntries: [
        new OverlayEntry(
          builder: (BuildContext context) => new Foo(),
        ),
      ],
    ),
  );
}

class Foo extends StatefulWidget {
  @override
  FooState createState() => new FooState();
}

class FooState extends State<Foo> {
  bool _includeDraggable = true;
  @override
  Widget build(BuildContext context) {
    Widget target = new Container(
      width: 100.0,
      height: 100.0,
      decoration: new BoxDecoration(
        backgroundColor: new Color(0xFF00FFFF),
      ),
    );
    Widget draggable = new Container(
      width: 100.0,
      height: 100.0,
      decoration: new BoxDecoration(
        backgroundColor: new Color(0xFFFFFF00),
      ),
    );
    List<Widget> stackChildren = [
      _includeDraggable
          ? new Draggable<int>(
              data: 1,
              dragAnchor: DragAnchor.pointer,
              maxSimultaneousDrags: 1,
              childWhenDragging: draggable,
              feedback: draggable,
              child: draggable,
            )
          : draggable,
      new DragTarget<int>(
        onWillAccept: (int data) {
          setState(() {
            _includeDraggable = false;
          });
          return true;
        },
        onAccept: (int data) {},
        builder: (
          BuildContext context,
          List<int> candidateData,
          List<dynamic> rejectedData,
        ) =>
            target,
      ),
    ];
    return new Row(
      children: stackChildren,
    );
  }
}

Activity

  1. self-assigned this
    on Oct 15, 2016
  2. added a commit that references this issue on Oct 16, 2016
    06babb2
  3. github-actions commented on Sep 5, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  4. locked as resolved and limited conversation to collaborators on Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions