SingleChildScrollView 在嵌套列中不起作用。我的第二列没有使用 SingleChildScrollView 滚动

SingleChildScrollView not working in a nested Column. My second column is not scrolling using SingleChildScrollView

SingleChildScrollView 无法在嵌套列中工作。我的第二列没有使用 SingleChildScrollView

滚动
Widget build(BuildContext context) {
            return MaterialApp(
              home: Scaffold(
                body: Column(
                  children: [
                    Container(
                      height: 200,
                    ),
                    Container(
                      child: SingleChildScrollView(
                        child: Column(

                          children: [
                            Container(
                              color: Colors.purple,
                              height: 200,
                            ),
                            Container(
                              color: Colors.orange,
                              height: 200,
                            ),
                            Container(
                              color: Colors.red,
                              height: 200,
                            ),
                            Container(
                              color: Colors.yellow,
                              height: 200,
                            ),
                          ],
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            );
          }

当我使用 SingleChildScrollView 时第二列不滚动

尝试将 Container 包装到 Expanded Widget 中。如果它不起作用,请尝试包装 SingleChildScrollView 或第二个 Column

您应该使用 Expanded 作为 SingleChildScrollView 的父级:

Widget build(BuildContext context) {
  return MaterialApp(
    home: Scaffold(
      body: Column(
        children: [
          Container(
            height: 200,
          ),
          Expanded(
            child: SingleChildScrollView(
              child: Column(
                children: [
                  Container(
                    color: Colors.purple,
                    height: 200,
                  ),
                  Container(
                    color: Colors.orange,
                    height: 200,
                  ),
                  Container(
                    color: Colors.red,
                    height: 200,
                  ),
                  Container(
                    color: Colors.yellow,
                    height: 200,
                  ),
                ],
              ),
            ),
          ),
        ],
      ),
    ),
  );
}