如何在 Flutter 中制作水平可滚动表格小部件

发布于 2025-01-11 13:22:43 字数 76 浏览 6 评论 0原文

我想在 Flutter 中使表列在水平方向上可滚动。如何做到这一点?还记得谈论 Table Widget 而不是 DataTable 吗?

I want to make Table Columns in Scrollable horizontal direction In Flutter. How to do achieve that? Remember Talking about Table Widget not DataTable?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

假情假意假温柔 2025-01-18 13:22:43

您可以尝试使 flutter table 小部件水平滚动,

Scrollbar(
    child: ListView(
      children: [
        SingleChildScrollView(
          scrollDirection: Axis.horizontal,
          child: Table(
            defaultColumnWidth: IntrinsicColumnWidth(),
            border: TableBorder.all(color: Colors.grey.shade200, width: 5),
            children: [
              TableRow(children: [
                Padding(
                    padding:
                        EdgeInsets.symmetric(vertical: 15, horizontal: 40),
                    child: Center(
                        child: Text(
                      'Title 1',
                      style: customTextStyle,
                    ))),
                Padding(
                    padding:
                    EdgeInsets.symmetric(vertical: 15, horizontal: 40),
                    child: Center(
                        child: Text(
                          'Title 2',
                          style: customTextStyle,
                        ))),
                Padding(
                    padding:
                    EdgeInsets.symmetric(vertical: 15, horizontal: 40),
                    child: Center(
                        child: Text(
                          'Title 3',
                          style: customTextStyle,
                        ))),
                Padding(
                    padding:
                    EdgeInsets.symmetric(vertical: 15, horizontal: 40),
                    child: Center(
                        child: Text(
                          'Title 4',
                          style: customTextStyle,
                        ))),
              ]),
              TableRow(children: [
                Padding(
                    padding:
                    EdgeInsets.symmetric(vertical: 15, horizontal: 40),
                    child: Center(
                        child: Text(
                          'Value 1',
                          style: customCellTextStyle,
                        ))),
                Padding(
                    padding:
                    EdgeInsets.symmetric(vertical: 15, horizontal: 40),
                    child: Center(
                        child: Text(
                          'Value 2',
                          style: customCellTextStyle,
                        ))),
                Padding(
                    padding:
                    EdgeInsets.symmetric(vertical: 15, horizontal: 40),
                    child: Center(
                        child: Text(
                          'Value 3',
                          style: customCellTextStyle,
                        ))),
                Padding(
                    padding:
                    EdgeInsets.symmetric(vertical: 15, horizontal: 40),
                    child: Center(
                        child: Text(
                          'Value 4',
                          style: customCellTextStyle,
                        ))),
              ]),
            ],
          ),
        ),
      ],
    ),
  ),

You can try this to make the flutter table widget horizontally scrollable,

Scrollbar(
    child: ListView(
      children: [
        SingleChildScrollView(
          scrollDirection: Axis.horizontal,
          child: Table(
            defaultColumnWidth: IntrinsicColumnWidth(),
            border: TableBorder.all(color: Colors.grey.shade200, width: 5),
            children: [
              TableRow(children: [
                Padding(
                    padding:
                        EdgeInsets.symmetric(vertical: 15, horizontal: 40),
                    child: Center(
                        child: Text(
                      'Title 1',
                      style: customTextStyle,
                    ))),
                Padding(
                    padding:
                    EdgeInsets.symmetric(vertical: 15, horizontal: 40),
                    child: Center(
                        child: Text(
                          'Title 2',
                          style: customTextStyle,
                        ))),
                Padding(
                    padding:
                    EdgeInsets.symmetric(vertical: 15, horizontal: 40),
                    child: Center(
                        child: Text(
                          'Title 3',
                          style: customTextStyle,
                        ))),
                Padding(
                    padding:
                    EdgeInsets.symmetric(vertical: 15, horizontal: 40),
                    child: Center(
                        child: Text(
                          'Title 4',
                          style: customTextStyle,
                        ))),
              ]),
              TableRow(children: [
                Padding(
                    padding:
                    EdgeInsets.symmetric(vertical: 15, horizontal: 40),
                    child: Center(
                        child: Text(
                          'Value 1',
                          style: customCellTextStyle,
                        ))),
                Padding(
                    padding:
                    EdgeInsets.symmetric(vertical: 15, horizontal: 40),
                    child: Center(
                        child: Text(
                          'Value 2',
                          style: customCellTextStyle,
                        ))),
                Padding(
                    padding:
                    EdgeInsets.symmetric(vertical: 15, horizontal: 40),
                    child: Center(
                        child: Text(
                          'Value 3',
                          style: customCellTextStyle,
                        ))),
                Padding(
                    padding:
                    EdgeInsets.symmetric(vertical: 15, horizontal: 40),
                    child: Center(
                        child: Text(
                          'Value 4',
                          style: customCellTextStyle,
                        ))),
              ]),
            ],
          ),
        ),
      ],
    ),
  ),
玻璃人 2025-01-18 13:22:43

尝试一下,

Scrollbar(
      
        child: <Widget>[
          SingleChildScrollView(
            scrollDirection: Axis.horizontal,
            child: Table(
...

这些资源可能会对您或将来的任何人有所帮助,https://github .com/flutter/flutter/issues/35445

Try this,

Scrollbar(
      
        child: <Widget>[
          SingleChildScrollView(
            scrollDirection: Axis.horizontal,
            child: Table(
...

These are some sources that might help you or any one in future, https://github.com/flutter/flutter/issues/35445 ,

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文