如何避免在列/换行小部件中颤动时渲染溢出?

时间:2021-03-25 19:22:09

标签: flutter flutter-layout

在这里,每当我增加绿色容器的大小时,我都想避免渲染溢出(我不想使其可滚动)。 红色容器具有可滚动列表视图作为子项。我尝试过包装,但无法避免溢出。此外,如果我尝试将 listview builder 的容器包装到扩展中,则会出现错误。基本上绿色容器将包含电影描述,我希望红色容器中的建议相应地调整它们的大小。任何人都可以帮忙吗? 这是脚手架主体的代码:

Column(
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Container(
                width: 100,
                child: TextField(
                  keyboardType: TextInputType.number,
                  onChanged: (str) {
                    s1 = str;
                  },
                  onEditingComplete: () {
                    in1 = double.parse(s1);
                  },
                ),
              ),
            ],
          ),
          SizedBox(
            height: 30,
          ),
          Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Card(
                child: Row(
                  children: [
                    Container(
                      padding: EdgeInsets.only(top: 5, bottom: 5),
                      width: 100,
                      child: SingleChildScrollView(
                        scrollDirection: Axis.horizontal,
                        child: Text('fytfffffffffffffffffffffffffff'),
                      ),
                    ),
                    SizedBox(
                      width: 20,
                    ),
                    Text('4.0'),
                  ],
                ),
              ),
              Column(
                children: [
                  Container(
                    width: 200,
                    color: Colors.green,
                    height: 100,
                  ),
                  Text('Reccomendations'),
                  Container(
                    color: Colors.red,
                    height: 200,
                    width: 200,
                    child: ListView.builder(
                        itemCount: recommendations.length,
                        itemBuilder: (context, i) {
                          return GestureDetector(
                            onTap: () {
                              print(i.toString());
                            },
                            child: Container(
                                child: Text(movies[recommendations[i]])),
                          );
                        }),
                  )
                ],
              )
            ],
          ),
        ],
      )

the photo

0 个答案:

没有答案