Flutter dart 错误(导致错误的相关小部件是...)

dem*_*eph 1 widget dart visual-studio-code flutter

由于我的小部件的大小或数据(我猜),我收到多个错误。\n我尝试重新编写这部分,但它不起作用。\n是因为小部件的大小还是其他原因?

\n
 @override\n Widget build(BuildContext context) {\n   var questionsOf = widget.setType(InputPage.topicN);\n\n   CollectionReference contestantsRef =\n       FirebaseFirestore.instance.collection(\'contestants\');\n\n   return Scaffold(\n     backgroundColor: Colors.blue,\n     appBar: AppBar(\n       centerTitle: true,\n     ),\n     body: SafeArea(\n         child: Column(\n       children: <Widget>[\n         Flexible(\n             child: Container(\n           height: 100,\n           child: iconCreate(),\n         )),\n         Container(\n           child: StreamBuilder<QuerySnapshot>(\n             stream: contestantsRef.snapshots(),\n             builder: (BuildContext context, AsyncSnapshot asyncSnapshot) {\n               List<DocumentSnapshot> listOfDocumentSnap =\n                   asyncSnapshot.data.docs;\n\n               return ListView.builder(\n                 itemBuilder: (context, index) {\n                   return Text(\'${listOfDocumentSnap[index].data()}\');\n                 },\n                 itemCount: listOfDocumentSnap.length,\n               );\n             },\n           ),\n         ),\n         SizedBox(\n           height: 100,\n         ),\n         Flexible(\n           flex: 4,\n           child: Container(\n             height: 200,\n             margin: EdgeInsets.all(20),\n             decoration:\n                 BoxDecoration(border: Border.all(color: Colors.black)),\n             child: Center(\n               child: StreamBuilder(\n                 stream: questionsOf.snapshots(),\n                 builder: (BuildContext context, AsyncSnapshot asyncsnapshot) {\n                   String question1 =\n                       asyncsnapshot.data.data()[\'q$questionIndexa\']\n                           [\'q$questionIndexa\' + \'Sent\'];\n                   return Text(\'$question1\');\n                 },\n               ),\n             ),\n           ),\n         ),\n         Flexible(\n             flex: 3,\n             child: Container(\n               child: Column(\n                 children: [\n                   buildAnswerBox(questionsOf, 1, questionIndexa),\n                   SizedBox(\n                     height: 10,\n                   ),\n                   buildAnswerBox(questionsOf, 2, questionIndexa),\n                   SizedBox(\n                     height: 10,\n                   ),\n                   buildAnswerBox(questionsOf, 3, questionIndexa),\n                   SizedBox(\n                     height: 10,\n                   ),\n                   buildAnswerBox(questionsOf, 4, questionIndexa),\n                 ],\n               ),\n             ))\n       ],\n     )),\n   );\n }\n
Run Code Online (Sandbox Code Playgroud)\n

这是错误部分:

\n
\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90 Exception caught by rendering library \xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\nRenderBox was not laid out: RenderCustomPaint#60178 relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE\n\'package:flutter/src/rendering/box.dart\':\npackage:flutter/\xe2\x80\xa6/rendering/box.dart:1\nFailed assertion: line 1929 pos 12: \'hasSize\'\n\nThe relevant error-causing widget was\nListView\nlib\\guess_page.dart:74\n\n\n\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90 Exception caught by rendering library \xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\nRenderBox was not laid out: RenderRepaintBoundary#c207a relayoutBoundary=up3 NEEDS-PAINT\n\'package:flutter/src/rendering/box.dart\':\npackage:flutter/\xe2\x80\xa6/rendering/box.dart:1\nFailed assertion: line 1929 pos 12: \'hasSize\'\n\nThe relevant error-causing widget was\nColumn\nlib\\guess_page.dart:60\n\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\n
Run Code Online (Sandbox Code Playgroud)\n

毕竟我得到的是像这样的平面蓝屏

\n

在此输入图像描述

\n

我尝试过的事情。\n首先,我认为这是因为流构建器,我尝试更改流构建器和列表视图部分,但它不起作用。\n比我用扩展和灵活的方式包装小部件(给定的柔性),但它也没用。

\n

Har*_*rsh 11

在 ListView 中使用这些属性

shrinkWrap: true,
physics: BouncingScrollPhysics(),
Run Code Online (Sandbox Code Playgroud)


小智 5

将此属性添加到您的 listview.builder 中

physics: const BouncingScrollPhysics(),
Run Code Online (Sandbox Code Playgroud)