森 • 时光机

Flutter 长按控件在对应位置弹出 Menu 菜单 (含震动反馈)

GestureDetector(
  child: ,
  onLongPressStart: (details) {
    Feedback.forLongPress(this.context); // Add Feedback
    showMenu(
      context: context,
      position: RelativeRect.fromLTRB(
        details.globalPosition.dx,
        details.globalPosition.dy,
        details.globalPosition.dx,
        details.globalPosition.dy,
      ),
      items: <PopupMenuEntry>[
        PopupMenuItem(child: Text("删除")), // Menu Item
      ],
    );
  },
);

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »