如何通过“ onLongpress”从ListView创建卡?

时间:2019-06-04 12:00:04

标签: flutter

我正在尝试创建一个卡,只要在ListTile中的某个条目被按下几秒钟(onLongpress)时就创建该卡。 通过放大地图,onTap函数可以完美地工作,但是以相同方式将onLongpress方法插入代码中时,什么也不会发生。

基本上,ExpansionTile的ListTile ist部分显示一些其他信息,例如图像和一些文本。从Firestore连接到数据库的所有内容。 从我所看到的情况来看,onLongpress无法应用于ExpansionTile,因此我专注于将ListTile条目用于onLongpress方法。 我试图将其包装到GestureDetector中,但这都不起作用(我可能以错误的方式实现了它)。 我与mapcontroller一起工作是因为ExpansionTile是Flexible的一部分。在其顶部有一个Google Map。

´´´

return ListView.builder(
  itemCount: documents.length,
  itemBuilder: (builder, index) {
    final document = documents[index];
    return ExpansionTile(
      leading: new CircleAvatar(
        radius: 20.0,
        backgroundColor: Colors.white,
        backgroundImage: NetworkImage(document['icon']),
      ),
      title: Text(document['name']),
      children: <Widget>[
      new ListTile(
        trailing: new CircleAvatar(
          radius: 50.0,
          backgroundColor: Colors.white,
          backgroundImage: NetworkImage(document['image']),
          ),
        subtitle: Text(document['text']),
        onTap: () async {
        final controller = await mapController.future;
        await controller.animateCamera(CameraUpdate.newCameraPosition(
          CameraPosition(
            target: LatLng(
              document['location'].latitude,
              document['location'].longitude,
            ),
            zoom: 15,
          )
        ));
      },
      ),
    ],
    );
  },
);

´´´

当前,当按住ListTile条目一段时间时,该应用程序什么也不做,除了Splash动画。该卡本身不应成为一个全新的窗口;相反,它应该位于可弯曲的顶部,该柔性会在后台有点“灰”。

0 个答案:

没有答案