-1

如何在垂直滚动小部件(SinglechildScrollview)中使用滚动条水平滚动?

4

1 回答 1

0

你可以试试这个例子,

class TestScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Container(
        padding: const EdgeInsets.all(10),
        child: SingleChildScrollView(
          child: Column(
            children: [
              SingleChildScrollView(
                scrollDirection: Axis.horizontal,
                padding: const EdgeInsets.symmetric(vertical: 10),
                child: Row(
                  children: [1,2,3,4,5].map((url) {
                    return Container(
                      width: 100.0,
                      height: 100.0,
                      margin: EdgeInsets.symmetric(horizontal: 5.0),
                      decoration: BoxDecoration(
                        color: Colors.red,
                      ),
                    );
                  }).toList(),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

让我知道它是否对你有帮助。

于 2021-05-13T06:57:07.707 回答