首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >Flutter :每个Listtile的弹出窗口

Flutter :每个Listtile的弹出窗口
EN

Stack Overflow用户
提问于 2021-07-10 15:20:18
回答 1查看 75关注 0票数 0

我正在从事一个颤动项目,我想弹出点击一个特定的瓷砖生成。这是我的代码

这是我的ListTile生成器

代码语言:javascript
运行
AI代码解释
复制
Future<Widget> getRecordView()  {
      print("405 name " + name.toString());
      print(nameArr);
      var items = List<Record>.generate(int.parse(widget.vcont), (index) => Record(
        name: nameArr[index],
        type: typeArr[index],
        address: addressArr[index],
        state: stateArr[index],
        phone:phoneArr[index],
        city: cityArr[index],
        id: idArr[index],
      ));
      print("Started");
      var listItems =  items;
      var listview = ListView.builder(
          itemCount: int.parse(widget.vcont),
          itemBuilder: (context,index){
            return listItems[index] ;
          }
      );
      return Future.value(listview);
  }

我需要的弹出窗口:

代码语言:javascript
运行
AI代码解释
复制
Future <bool> details(BuildContext context,String type) {
    return  Alert(
      context: context,
      type: AlertType.success,
      title: "Submission",
      desc: type,  //The parameter
      buttons: [
        DialogButton(
          child: Text(
            "OKAY",
            style: TextStyle(color: Colors.white, fontSize: 20),
          ),
          onPressed: () => Navigator.pop(context),
          color: Color.fromRGBO(0, 179, 134, 1.0),
          radius: BorderRadius.circular(0.0),
        ),
      ],
    ).show();
  }

我试图用GestureDetector和Inkwell来包装Record,但是我只得到了错误,Android Studio告诉我在那个上下文中不应该使用Record。我在网上查了查,找不到关于这件事的任何东西。请帮帮忙。

EN

回答 1

Stack Overflow用户

发布于 2021-07-10 15:36:48

记录,据我所知,这只是一个模型,而不是一个小部件。项目生成器需要小部件。您应该将传递给项构建器的内容与实际的小部件包装在一起,如容器()、ListTile()、..这些小部件可以用手势检测器包装,以执行您想要的弹出窗口。

它看起来就像这样

代码语言:javascript
运行
AI代码解释
复制
var listview = ListView.builder(
   itemCount: items.length,
   itemBuilder: (context, index) {
      return GestureDetector(
        onTap: () {
          // Tap on an item in the list and this will get executed.
        },
        // Return an actual widget, I'm using a ListTile here, but you can
        // use any other type of widget here or a create custom widget.
        child: ListTile(
          // this will display the record names as list tiles.
          title: Text(items[index].name),
      ),
    );
  },
);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68329036

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档