【问题标题】:how to display detailed information after clicking a gridview in flutter在flutter中单击gridview后如何显示详细信息
【发布时间】:2019-11-06 04:56:59
【问题描述】:

抱歉英语不好..
我想根据 gridview 项目的 id 从一个屏幕导航到另一个屏幕。
单击列表视图 item11 之一时,它将被定向到详细页面 item11.. 那么,当 ListView 的点击次数不同时,如何创建详细的页面设计。
完整我的代码:

class CategoryScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new SafeArea(
      child: new Scaffold(
        appBar: new BankAndaAppBar(),

        body: new Container(

          color: Colors.grey[100],
          child: new ListView(
            physics: ClampingScrollPhysics(),
            children: <Widget>[
              new Container(
                  padding: EdgeInsets.only(left: 12.0, right: 12.0, top: 12.0),
                  color: Colors.grey[100],
                  child: new Column(
                    children: <Widget>[
                      _bodyGridView(),
                    ],
                  )),
            ],
          ),
        ),
      ),
    );
  }

  Widget _bodyGridView() {
    return SingleChildScrollView(
      child: new Column(
        children: <Widget>[
          GridView.count(
            shrinkWrap: true,
            physics: NeverScrollableScrollPhysics(),
            crossAxisCount: 3,
            children: CATEGORIES_DUMMY_DATA
                .map((cat) => ListCategory(cat.id, cat.title, cat.titleDetail, cat.description, cat.image))
                .toList(),
          ),
        ],
      ),
    );
  }    
}

我想在单击 gridview 项目后显示详细信息。
示例:每次单击一个项目 1 显示详细视图 item=1。

enter image description here
谢谢。

【问题讨论】:

  • 请添加一些你的代码,你做了什么。
  • 已经添加了代码先生..

标签: flutter dart


【解决方案1】:

据我了解,您希望在单击网格项后显示详细信息。

如果是这样,有很多方法可以做到。

  1. 在页面内传递数据:follow
  2. 创建一个模型类,将数据存储在内存中并显示出来。 follow

如果您想从一个屏幕导航到另一个屏幕follow

【讨论】:

  • 是的,我想从一个屏幕导航到另一个屏幕,但内容数据不同。谢谢先生。
猜你喜欢
  • 2018-07-31
  • 2012-05-29
  • 2017-06-08
  • 2020-06-28
  • 1970-01-01
  • 1970-01-01
  • 2018-06-17
  • 2015-12-21
  • 1970-01-01
相关资源
最近更新 更多