【问题标题】:how to Add List in TabBarView in flutter如何在颤动的 TabBarView 中添加列表
【发布时间】:2021-10-26 16:38:48
【问题描述】:

我想添加 listviw 和 column 。 . . . . . .. . . .

。 . . . . ..

在“a”屏幕中我想显示列表。

但我不能,而且我遇到了错误。 不知道为什么。

谁能帮帮我?

这是我的代码的一部分:

 Expanded(
            child: Padding(
              padding: const EdgeInsets.only(top: 30),
              child: Container(
                width: 500,
                child: DefaultTabController(
                  length: 3,
                  child: Scaffold(
                    appBar: PreferredSize(
                      preferredSize: Size.fromHeight(50.0),
                      child: const TabBar(
                        tabs: <Widget>[
                          Tab(
                              text: "a",
                          ),
                          Tab(
                            text: "b",
                          ),
                          Tab(
                            text: "c",
                          ),
                        ],
                      ),
                    ),
                    body: const TabBarView(
                      children: <Widget>[
                        Center(
                            child: Text("a "),
//here i want to add listView
                        ),
                        Center(
                          child: Text("b"),
                        ),
                        Center(
                          child: Text("c"),
                        ),
                      ],
                    ),
                  ),
                ),
              ),
            ),
          ),

【问题讨论】:

  • 你能添加完整的小部件,包括状态类
  • 可以发个聊天链接吗?我已经发给你了
  • 您可以在问题上添加完整的小部件,以重现您面临的错误

标签: flutter dart listview center appbar


【解决方案1】:

只需删除 TabBarView 中的 'const'

            body: TabBarView(
              children: <Widget>[
                Center(
                    child: Text("a "),

                ),
                Center(
                  child: Text("b"),
                ),
                Center(
                  child: Text("c"),
                ),
              ],

【讨论】:

  • 请添加更多详细信息以扩展您的答案,例如工作代码或文档引用。
猜你喜欢
  • 2022-10-15
  • 2021-11-23
  • 2019-01-06
  • 2019-05-02
  • 1970-01-01
  • 1970-01-01
  • 2021-04-03
  • 2021-01-31
  • 2019-05-10
相关资源
最近更新 更多