English 中文(简体)
单身婴儿喂养 观点
原标题:Flutter Column inside SingleChildScrollView doesn t scroll

当我试图在单一儿童发展中心使用卡片时 我认为,我有这一错误:

The following assertion was thrown during layout:
A RenderFlex overflowed by 178 pixels on the bottom.

The relevant error-causing widget was: 
  Column file:///C:/Users/emirs/AndroidStudioProjects/view_met/lib/home.dart:197:16
The overflowing RenderFlex has an orientation of Axis.vertical.
The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and black striped pattern. This is usually caused by the contents being too big for the RenderFlex.

Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the RenderFlex to fit within the available space instead of being sized to their natural size.
This is considered an error condition because it indicates that there is content that cannot be seen. If the content is legitimately bigger than the available space, consider clipping it with a ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex, like a ListView.

The specific RenderFlex in question is: RenderFlex#d861f relayoutBoundary=up2 OVERFLOWING
...  needs compositing
...  parentData: offset=Offset(0.0, 0.0) (can use size)
...  constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=820.6)
...  size: Size(411.4, 820.6)
...  direction: vertical
...  mainAxisAlignment: start
...  mainAxisSize: max
...  crossAxisAlignment: center
...  verticalDirection: down
◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤

这是我的法典:

Padding(
                padding: EdgeInsets.fromLTRB(0, 20, 0, 0),
                child: Column(
                  children: <Widget>[
                    Text("Random Items You Could Like", style: GoogleFonts.merriweather(fontSize: 18, color: Colors.black)),
                    SingleChildScrollView(
                      scrollDirection: Axis.vertical,
                      child: Column(
                       children: <Widget>[
                         builder(randint1.toString()),
                         builder(randint2.toString()),
                         builder(randint3.toString()),
                         builder(randint4.toString()),
                         builder(randint5.toString()),
                       ],
                      )
                    ),
                  ],
                ),
              )

代表:

builder(String id) {
      return FutureBuilder(
        future: fetchData(id),
        builder: (BuildContext context, snapshot) {
          if (snapshot.connectionState == ConnectionState.waiting) {
            return Padding(
              padding: EdgeInsets.fromLTRB(0, 20, 0, 0),
              child: CircularProgressIndicator(),
            );
          }
          var data = jsonDecode(snapshot.data.toString());

          var leading;
          var artist;


          if (data["primaryImageSmall"] == "") {
            leading = Icon(Icons.dangerous);
          }
          else {
            leading = Image.network(data["primaryImageSmall"]);
          }

          if (data["artistDisplayName"]== "") {
            artist = "Unknown";
          }
          else {
            artist = data["artistDisplayName"];
          }

          return Card(
            clipBehavior: Clip.antiAlias,
            child: Column(
              children: [
                ListTile(
                  leading: leading,
                  title: Text(data["title"]),
                  subtitle: Text(
                    "by $artist",
                    style: TextStyle(color: Colors.black.withOpacity(0.6)),
                  ),
                ),
                ButtonBar(
                  alignment: MainAxisAlignment.start,
                  children: [
                    TextButton(
                      onPressed: () {
                        Navigator.push(
                          context,
                          MaterialPageRoute(builder: (context) => DetailsPage()),
                        );
                      },
                      child: Text("Details", style: TextStyle(color: Color(0xFF6200EE))),
                    ),
                    TextButton(
                      onPressed: () {
                        Navigator.push(
                          context,
                          MaterialPageRoute(builder: (context) => DetailsPage()),
                        );
                      },
                      child: Text("Add to Favorites", style: TextStyle(color: Color(0xFF6200EE))),
                    ),
                  ],
                ),
              ],
            ),
          );
        },
      );
    }

结果是:

enter image description here

我也审视了其他问题,但没有任何问题得到实际帮助,他们没有找到我正在寻求的答案。 我确实不知道目前的情况。 我感谢任何类型的帮助。 如果需要,我可以提供更多信息。

最佳回答

Wrap the SingleChildScrollView with Expanded.

Column(
  children: [
    // ...
    Expanded(
      child: SingleChildScrollView(),
    ),
  ],
),
问题回答

我认为,你正在使用<代码>。 单项《儿童发展评论》()错误地删除了<条码>,《儿童发展评论》()和《儿童发展评论》;将其用于总结这一部分:

Column(
                          children: <Widget>[
                            builder(randint1.toString()),
                            builder(randint2.toString()),
                            builder(randint3.toString()),
                            builder(randint4.toString()),
                            builder(randint5.toString()),
                          ],

它希望:

SingleChildScrollView(
                    scrollDirection: Axis.vertical,
Column(
                          children: <Widget>[
                            builder(randint1.toString()),
                            builder(randint2.toString()),
                            builder(randint3.toString()),
                            builder(randint4.toString()),
                            builder(randint5.toString()),
                          ],
),

www.un.org/Depts/DGACM/index_spanish.htm 提 出 ∗∗∗∗

 Padding(
              padding: EdgeInsets.fromLTRB(0, 20, 0, 0),
              child: Stack(
                children: [
                  Align(
                    alignment:Alignment.topCenter,
                      child: Text("Random Items You Could Like", style: GoogleFonts.merriweather(fontSize: 18, color: Colors.black))),
                  SingleChildScrollView(
                    scrollDirection: Axis.vertical,
                    child: Column(
                      children: <Widget>[
                        Column(
                          children: <Widget>[
                            builder(randint1.toString()),
                            builder(randint2.toString()),
                            builder(randint3.toString()),
                            builder(randint4.toString()),
                            builder(randint5.toString()),
                          ],
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            )

遵循法典对我工作。 采用以下代码: 页: 1

Column(
children :[
    Expanded(
                child: SingleChildScrollView(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.start,
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      Text("Monat".toUpperCase(),
                          style: TextStyle(
                            color: Colors.black,
                            fontSize: 20,
                          )),
              ],
    ),
    ),
],
);




相关问题
Flutter App cannot be installed on Android TV

I m building a Flutter app that should support Android TV and Mobile devices. Despite Google Play shows that it is supported, I cannot install app on my MiBox device. While trying to install it, both ...

Moving the icon button to the right causes rendering issues

I am trying to align the icon button to the right of the Text field, I tried the row which made the icon button not centered vertically and now I am trying out the Stack widget. Here is my code - ...

热门标签