Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android gridview.count不';涡旋颤振_Android_Ios_Flutter_Gridview_Overflow - Fatal编程技术网

Android gridview.count不';涡旋颤振

Android gridview.count不';涡旋颤振,android,ios,flutter,gridview,overflow,Android,Ios,Flutter,Gridview,Overflow,在我的应用程序中,我将gridview.count放在列小部件中,但gridview.count不会滚动并在底部溢出,所以请给出一些建议 这是我的密码 @override Widget build(BuildContext context) { return Stack( children: <Widget>[ Image.asset( "images/background.png", height: MediaQuery

在我的应用程序中,我将gridview.count放在列小部件中,但gridview.count不会滚动并在底部溢出,所以请给出一些建议

这是我的密码

 @override
 Widget build(BuildContext context) {
 return Stack(
  children: <Widget>[
    Image.asset(
      "images/background.png",
      height: MediaQuery.of(context).size.height,
      width: MediaQuery.of(context).size.width,
      fit: BoxFit.fill,
    ),
    Scaffold(
      backgroundColor: Color(0x00000000),
      body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              Container(
                child: Padding(
                  padding: EdgeInsets.only(top: 50,bottom: 10),
                  child: Row(
                    children: <Widget>[
                      Spacer(flex: 2),
                      Text(
                        'Interests',
                        textAlign: TextAlign.center,
                        overflow: TextOverflow.ellipsis,
                        maxLines: 1,
                        style: TextStyle(
                          color: Color(0xFF0066CB),
                          fontSize: 20.0,
                        ),
                      ),
                      Spacer(),
                      Expanded(
                        child:SvgPicture.asset(
                          "images/vector.svg",
                          height: 30.0,
                          width: 30.0,
                        ),
                      )
                    ],
                  ),
                ),
              ),
              Padding(
                padding: EdgeInsets.only(top: 10,bottom: 90,left: 10,right: 10),
                child: GridView.count(
                     scrollDirection: Axis.vertical,
                     crossAxisCount: 3,
                     crossAxisSpacing: 5.0,
                     mainAxisSpacing: 5.0,
                     shrinkWrap: true,
                     children: List.generate(20, (index) {
                       return Padding(
                         padding: EdgeInsets.all(5.0),
                         child: Container(
                           child: SvgPicture.asset(
                             "images/register_top_logo_new.svg",
                           ),
                           padding: EdgeInsets.all(20.0),
                           height: 135.0,
                           width: 135.0,
                           decoration: BoxDecoration(
                             border: Border.all(
                               width: 1.0,
                               color: Color(0xFFF9AD16),
                             ),
                           ),
                         ),
                       );
                     },
                     ),
                   ),
              ),
            ],
          ),
       ),
     ),
    ],
   );
 }
@覆盖
小部件构建(构建上下文){
返回堆栈(
儿童:[
影像资产(
“images/background.png”,
高度:MediaQuery.of(context).size.height,
宽度:MediaQuery.of(context).size.width,
fit:BoxFit.fill,
),
脚手架(
背景颜色:颜色(0x00000000),
正文:中(
子:列(
mainAxisAlignment:mainAxisAlignment.start,
crossAxisAlignment:crossAxisAlignment.center,
儿童:[
容器(
孩子:填充(
填充:仅限边缘设置(顶部:50,底部:10),
孩子:排(
儿童:[
垫片(挠性:2),
正文(
"利益",,
textAlign:textAlign.center,
溢出:TextOverflow.省略号,
maxLines:1,
样式:TextStyle(
颜色:颜色(0xFF0066CB),
字体大小:20.0,
),
),
垫片(),
扩大(
子项:SvgPicture.asset(
“images/vector.svg”,
身高:30.0,
宽度:30.0,
),
)
],
),
),
),
填充物(
填充:仅限边集(顶部:10,底部:90,左侧:10,右侧:10),
子项:GridView.count(
滚动方向:轴垂直,
交叉轴计数:3,
交叉轴间距:5.0,
主轴间距:5.0,
收缩膜:对,
子项:List.generate(20,(索引){
返回填充(
填充:所有边缘设置(5.0),
子:容器(
子项:SvgPicture.asset(
“images/register\u top\u logo\u new.svg”,
),
填充:所有边缘设置(20.0),
身高:135.0,
宽度:135.0,
装饰:盒子装饰(
边界:边界(
宽度:1.0,
颜色:颜色(0xFFF9AD16),
),
),
),
);
},
),
),
),
],
),
),
),
],
);
}
这是我运行应用程序时得到的日志

I/flutter (16748): The relevant error-causing widget was:
I/flutter (16748):   Column
I/flutter (16748):   file:///C:/Users/mayur/AndroidStudioProjects/flutter/webinar-mobile/lib/activities/interests_activity.dart:30:22
I/flutter (16748): 
I/flutter (16748): The overflowing RenderFlex has an orientation of Axis.vertical.
I/flutter (16748): The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and
I/flutter (16748): black striped pattern. This is usually caused by the contents being too big for the RenderFlex.
I/flutter (16748): Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the
I/flutter (16748): RenderFlex to fit within the available space instead of being sized to their natural size.
I/flutter (16748): This is considered an error condition because it indicates that there is content that cannot be
I/flutter (16748): seen. If the content is legitimately bigger than the available space, consider clipping it with a
I/flutter (16748): ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex,
I/flutter (16748): like a ListView.
I/flutter (16748): The specific RenderFlex in question is: RenderFlex#42dda relayoutBoundary=up5 OVERFLOWING:
I/flutter (16748):   needs compositing
I/flutter (16748):   creator: Column ← Center ← _BodyBuilder ← MediaQuery ← LayoutId-[<_ScaffoldSlot.body>] ←
I/flutter (16748):     CustomMultiChildLayout ← AnimatedBuilder ← DefaultTextStyle ← AnimatedDefaultTextStyle ←
I/flutter (16748):     _InkFeatures-[GlobalKey#417d7 ink renderer] ← NotificationListener<LayoutChangedNotification> ←
I/flutter (16748):     PhysicalModel ← ⋯
I/flutter (16748):   parentData: offset=Offset(0.0, 0.0) (can use size)
I/flutter (16748):   constraints: BoxConstraints(0.0<=w<=360.0, 0.0<=h<=640.0)
I/flutter (16748):   size: Size(360.0, 640.0)
I/flutter (16748):   direction: vertical
I/flutter (16748):   mainAxisAlignment: start
I/flutter (16748):   mainAxisSize: max
I/flutter (16748):   crossAxisAlignment: center
I/flutter (16748):   verticalDirection: down
I/flutter (16748): ◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤
I/flutter (16748): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (16748): unhandled element metadata; Picture key: AssetBundlePictureKey(bundle: PlatformAssetBundle#bcd18(), name: "images/register_top_logo_new.svg", colorFilter: null)
I/flatter(16748):导致错误的相关小部件是:
I/颤振(16748):立柱
I/颤振(16748):file:///C:/Users/mayur/AndroidStudioProjects/flutter/webinar-移动/lib/activities/interests\u activity.dart:30:22
I/颤振(16748):
I/颤振(16748):溢出的RenderFlex具有轴垂直方向。
I/flatter(16748):溢出的RenderFlex的边缘在渲染中用黄色和黄色标记
I/颤振(16748):黑色条纹图案。这通常是由于RenderFlex的内容太大造成的。
I/flflt(16748):考虑应用Flex因子(例如使用扩展小部件)来强迫孩子们
I/颤振(16748):RenderFlex适合可用空间,而不是按照其自然大小进行调整。
I/颤振(16748):这被认为是一种错误情况,因为它表明存在无法识别的内容
I/颤振(16748):可见。如果内容合法地大于可用空间,考虑将其剪辑为
I/flatter(16748):将ClipRect小部件放入flex或使用可滚动容器而不是flex之前,
I/flatter(16748):像一个列表视图。
I/颤振(16748):所讨论的特定RenderFlex是:RenderFlex#42dda relayoutBoundary=up5溢出:
I/颤振(16748):需要合成
I/flatter(16748):创建者:列← 居中← _健美运动员← MediaQuery← LayoutId-[]←
I/颤振(16748):自定义多子女布局← 动画生成器← DefaultTextStyle← 动画默认文本样式←
I/flatter(16748):_InkFeatures-[GlobalKey 417d7墨水渲染器]← 通知侦听器←
I/颤振(16748):物理模型← ⋯
I/颤振(16748):父数据:偏移=偏移(0.0,0.0)(可以使用大小)

I/flatter(16748):约束:框约束(0.0Add
SingleChildScrollView
Over
Column
,它将滚动内部GridView也添加

物理:
NeverScrollableScrollPhysics()
,内部

GridView.count(
//.... existing code
physics: NeverScrollableScrollPhysics(),
)

这是因为Column和Gridview都占据了屏幕的全部高度,所以这里应该停止滚动。因此,使用
NeverScrollableScrollPhysics
,我们告诉GridView不要滚动,这样父部件就可以滚动

代码:

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("ListView Sample"),
      ),
      body: Stack(
        children: <Widget>[
          Image.asset(
            "images/background.png",
            height: MediaQuery.of(context).size.height,
            width: MediaQuery.of(context).size.width,
            fit: BoxFit.fill,
          ),
          Scaffold(
            backgroundColor: Color(0x00000000),
            body: Center(
              child: SingleChildScrollView(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Container(
                      child: Padding(
                        padding: EdgeInsets.only(top: 50, bottom: 10),
                        child: Row(
                          children: <Widget>[
                            Spacer(flex: 2),
                            Text(
                              'Interests',
                              textAlign: TextAlign.center,
                              overflow: TextOverflow.ellipsis,
                              maxLines: 1,
                              style: TextStyle(
                                color: Color(0xFF0066CB),
                                fontSize: 20.0,
                              ),
                            ),
                            Spacer(),
                            Expanded(
                              child: Container(
                                height: 30.0,
                                width: 30.0,
                              ),
                            )
                          ],
                        ),
                      ),
                    ),
                    Padding(
                      padding: EdgeInsets.only(
                          top: 10, bottom: 90, left: 10, right: 10),
                      child: GridView.count(
                        scrollDirection: Axis.vertical,
                        crossAxisCount: 3,
                        crossAxisSpacing: 5.0,
                        mainAxisSpacing: 5.0,
                        shrinkWrap: true,
                        physics: NeverScrollableScrollPhysics(),
                        children: List.generate(
                          20,
                          (index) {
                            return Padding(
                              padding: EdgeInsets.all(5.0),
                              child: Container(
                                padding: EdgeInsets.all(20.0),
                                height: 135.0,
                                width: 135.0,
                                decoration: BoxDecoration(
                                  border: Border.all(
                                    width: 1.0,
                                    color: Color(0xFFF9AD16),
                                  ),
                                ),
                              ),
                            );
                          },
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
@覆盖
小部件构建(构建上下文){
返回脚手架(
appBar:appBar(
标题:文本(“列表视图示例”),
),
主体:堆栈(
儿童:[
影像资产(
“images/background.png”,
高度:MediaQuery.of(context).size.height,
宽度:MediaQuery.of(context).size.width,
fit:BoxFit.fill,
),
脚手架(
背景颜色:颜色(0x00000000),
正文:中(
子:SingleChildScrollView(
子:列(
mainAxisAlignment:mainAxisAlignment.start,
铬
Expanded(
   child: Padding(
                padding: EdgeInsets.only(top: 10,bottom: 90,left: 10,right: 10),
                child: GridView.count(
                     scrollDirection: Axis.vertical,
                     crossAxisCount: 3,
                     crossAxisSpacing: 5.0,
                     mainAxisSpacing: 5.0,
                     shrinkWrap: true,
                     children: List.generate(20, (index) {
                       return Padding(
                         padding: EdgeInsets.all(5.0),
                         child: Container(
                           child: SvgPicture.asset(
                             "images/register_top_logo_new.svg",
                           ),
                           padding: EdgeInsets.all(20.0),
                           height: 135.0,
                           width: 135.0,
                           decoration: BoxDecoration(
                             border: Border.all(
                               width: 1.0,
                               color: Color(0xFFF9AD16),
                             ),
                           ),
                         ),
                       );
                     },
                     ),
                   ),
              ),
)