Flutter水平滚动条未显示

6bc51xsx  于 2023-03-31  发布在  Flutter
关注(0)|答案(1)|浏览(237)

这是我的代码:

final _horizontalScrollController = ScrollController();
 final _verticalScrollController = ScrollController();
 
 Widget displayTable(bool isValid) {
    return Column(
      children: [
        Expanded(
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: Container(
              width: double.infinity,
              color: Colors.white,
              child: Visibility(
                visible: isLoading,
                replacement: RefreshIndicator(
                  onRefresh: () {
                    setState(() {
                      isValid = true;
                    });
                    return callMyFunction();
                  },
                  child: Scrollbar(
                    controller: _verticalScrollController,
                    thumbVisibility: true,
                    trackVisibility: true,
                    child: Scrollbar(
                      controller: _horizontalScrollController,
                      thumbVisibility: true,
                      trackVisibility: true,
                      child: SingleChildScrollView(
                        controller: _verticalScrollController,
                        child: SingleChildScrollView(
                          scrollDirection: Axis.horizontal,
                          controller: _horizontalScrollController,
                          child: DataTable(
                            columns: const [
                              // columns ...
                            ],
                            rows: [
                              // Rows ...
                            ],
                          ),
                        ),
                      ),
                    ),
                  ),
                ),
                child: Center(child: CircularProgressIndicator()),
              ),
            ),
          ),
        )
      ],
    );
  }

垂直轴工作和滚动条显示没有任何问题。
水平轴工作,但滚动条现在显示!
如何解决此问题?

UPDATE:(Flutter信息)

Flutter 3.7.8 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 90c64ed42b (9 days ago) • 2023-03-21 11:27:08 -0500
Engine • revision 9aa7816315
Tools • Dart 2.19.5 • DevTools 2.20.1
ovfsdjhp

ovfsdjhp1#

使用下面的属性查看滚动条

SingleChildScrollView(
  scrollDirection: Axis.horizontal,
  child: Container(),
  showHorizontalScrollIndicator: true,
),

相关问题