我需要构建一个基于日期选择的动态 ListView ,然后我将调用一个 API 来获取数据并相应地填充列表。然后在 ListView 本身的最后我有一个向下按钮,我按下它应该打开一个扩展面板。所以为了做一个列表,我调用一个函数 Widget buildDynamicList(BuildContext context) 来根据新数据动态填充新列表.我收到此错误。
I/flutter ( 3438): The following assertion was thrown during performResize():
I/flutter ( 3438): Vertical viewport was given unbounded height.
I/flutter ( 3438): Viewports expand in the scrolling direction to fill their container.In this case, a vertical
I/flutter ( 3438): viewport was given an unlimited amount of vertical space in which to expand. This situation
I/flutter ( 3438): typically happens when a scrollable widget is nested inside another scrollable widget.
在下面的第一列中,我画了一张卡片,我将在其中选择日期,在下面的下一列中,我将调用此函数 buildDynamicList(context)
new Column(
children: <Widget>[
Container(
margin: new EdgeInsets.fromLTRB(20, 10, 0, 0),
decoration: new BoxDecoration(
color:Color.fromRGBO(36, 46, 66, 1),
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(35),
bottomLeft: const Radius.circular(35)
),
),
width: double.infinity,
height: 55.0,
//child:Expanded(
child:Card(
color: Color.fromRGBO(36, 46, 66, 1),
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(35)
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
height: 40.0,
width: 50.0,
decoration: BoxDecoration(
color: Colors.blueAccent,
shape: BoxShape.circle,
border: new Border.all(
color: Colors.blue,
width: 2.5,
),
),
child: Icon(
Icons.calendar_today,
size: 25.0,
color: Colors.white,
),
),
Expanded(
child:
Column(
//mainAxisAlignment: MainAxisAlignment.center,
//mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
//new Row(
// mainAxisSize: MainAxisSize.max,
//children: <Widget>[
new Text(
"From", style: TextStyle(color:Colors.white),
),
new Text(
"01 Jan 2019", style: TextStyle(color:Colors.white),
),
// new Icon(Icons.account_circle)
//style: Theme.of(context).textTheme.body2
],
),
),
Expanded(
child:
Column(
//mainAxisAlignment: MainAxisAlignment.center,
//mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
//new Row(
// mainAxisSize: MainAxisSize.max,
//children: <Widget>[
new Text(
"To", style: TextStyle(color:Colors.white),
),
new Text(
"02 Jan 2019", style: TextStyle(color:Colors.white),
),
// new Icon(Icons.account_circle)
//style: Theme.of(context).textTheme.body2
],
),
),
],
)
),
//)
),
]
),
new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
buildDynamicList(context)
],
)
这是我为动态列表调用的函数。我尝试了很多选择,例如扩展、灵活等都给我错误。
Widget buildDynamicList(BuildContext context) {
return new Container(
//decoration: new BoxDecoration(border: new Border.all(width: 2.0)),
height:200,
//fit: FlexFit.loose ,
child: ListView.builder(
// shrinkWrap: true,
itemCount: vehicles.length,
itemBuilder: (BuildContext ctxt, int index) {
return new ListView(
children: <Widget>[
new Text("TEE"),
]
);
}
),
);
}
最佳答案
删除嵌套的 listview,因为它是不必要的:
Widget buildDynamicList(BuildContext context) {
return new Container(
//decoration: new BoxDecoration(border: new Border.all(width: 2.0)),
height:200,
//fit: FlexFit.loose ,
child: ListView.builder(
//shrinkWrap: true,
itemCount: vehicles.length,
itemBuilder: (BuildContext ctxt, int index) {
return Text("TEE"),
}
),
);
}
关于Flutter Vertical viewport 被赋予无限高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55062275/
我脑子里浮现出一些关于一种新编程语言的想法,所以我想我会尝试实现它。一位friend建议我尝试使用Treetop(Rubygem)来创建一个解析器。Treetop的文档很少,我以前从未做过这种事情。我的解析器表现得好像有一个无限循环,但没有堆栈跟踪;事实证明很难追踪到。有人可以指出入门级解析/AST指南的方向吗?我真的需要一些列出规则、常见用法等的东西来使用像Treetop这样的工具。我的语法分析器在GitHub上,以防有人希望帮助我改进它。class{initialize=lambda(name){receiver.name=name}greet=lambda{IO.puts("He
当我写下面的代码时:x=[1,2,3]x我得到这个输出:[1,2,3,[...]][1,2,3,[...]][1,2,3,[...]]我不应该只得到[1,2,3,[1,2,3]]吗?解释是什么? 最佳答案 这没什么奇怪的。数组的第四个元素就是数组本身,所以当你求第四个元素时,你得到的是数组,当你求第四个元素的第四个元素时,你得到的是数组,当你求第四个元素时,你得到的是数组。第四个元素的第四个元素的第四个元素的元素......你得到了数组。就这么简单。唯一有点不寻常的是Array#to_s检测到这样的递归,而不是进入无限循环,而是返回
我在使用Arel聚契约(Contract)一查询中的2列时遇到了问题。当我运行它时,在railsdev-server崩溃之前,整个服务器会卡住一分钟。我怀疑是无限循环:)。也许我误解了Arel的整个概念,如果有人能看一下,我将不胜感激。这个查询的预期结果是这样的:[{:user_id=>1,:sum_account_charges=>300,:sum_paid_debts=>1000},...]a_account_charges=Table(:account_charges)a_paid_debts=Table(:paid_debts)a_participants=Table(:exp
我下面有一个ruby脚本,它无限地打印从1开始的数字。如何通过终端中的中断(如“Ctrl+C”或键“q”)使脚本停止无限执行?a=0while(a)putsaa+=1#thecodeshouldquitifaninterruptofacharacterisgivenend在每次迭代中,不应询问用户输入。 最佳答案 使用Kernel.trap为Ctrl-C安装信号处理程序:#!/usr/bin/rubyexit_requested=falseKernel.trap("INT"){exit_requested=true}while!
编辑:(已解决)实际上它可能是因为无限循环而引发的我正在编码,在添加一个方法后我得到了这个:user_name@the_computer:/media/ECC3-C3B0/Prog/mts/src/mts$raketest--trace**Invoketest(first_time)**Executetest/home/user_name/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:stackleveltoodeep(SystemStackError)rakeabo
我和我的friend们正在做一些基本的Ruby练习来感受这门语言,我们遇到了一个我们还无法理解的有趣行为。基本上,我们正在创建一个tree只有一个类的数据类型,node,它只包含一个值和一个包含零个或多个nodes的数组.我们正在使用rspec的autospec测试运行程序。有一次,我们开始编写测试以禁止无限递归(循环树结构)。这是我们的测试:it"breaksonacircularreference,whichwewillfixlater"dotree1=Node.new1tree2=Node.new1tree2.add_childtree1tree1.add_childtree2(
我需要能够放置处理过的图像的尺寸。我的ImageUploader类中有:version:postdoprocess:resize_to_fit=>[200,nil]end有没有一种方法可以获得与此类似的图像尺寸?height=@picture.image_height(:post) 最佳答案 您可以调整并使用此处描述的方法:http://code.dblock.org/carrierwave-saving-best-image-geometry它添加了一个进程,然后调用Magick的方法来获取图像几何。代码:version:post
我正在尝试解决ProjectEuler问题#12:Thesequenceoftrianglenumbersisgeneratedbyaddingthenaturalnumbers.Sothe7thtrianglenumberwouldbe1+2+3+4+5+6+7=28.Thefirsttentermswouldbe:1,3,6,10,15,21,28,36,45,55,...Letuslistthefactorsofthefirstseventrianglenumbers:1:13:1,36:1,2,3,610:1,2,5,1015:1,3,5,1521:1,3,7,2128:1,2
这是一个很大的绊脚石。警告:以下不是问题,而是对我的想法的解释。我的问题是——你有更好的方法吗?是否有一些我不熟悉的常用技术?看起来这是一个微不足道的问题。所以你有任务模型。您可以创建任务、完成任务、销毁任务。然后你有经常性的任务。它就像常规任务一样,但它附加了一个重复规则。但是,任务可以无限期地重复——您可以在计划中提前一年,您应该会看到任务出现。因此,当用户创建一个循环任务时,您不会想在未来百年内构建数千个任务,并将它们保存到数据库中,对吧?所以我开始思考—如何创建它们?一种方法是在您查看日程安排时创建它们。因此,当用户提前一个月移动时,将创建任何重复性任务。当然,这意味着您不能再
我正在尝试创建一个无限循环,其中一段代码将永远执行。我找到的所有循环文档都警告不要创建无限循环,但没有有效示例。如果我有一段代码:{puts"foo"puts"bar"sleep300}我将如何永远运行这个block? 最佳答案 loopdoputs'foo'puts'bar'sleep300end 关于ruby-创建一个无限循环,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/2