我有一个 ListView ,它是动态构建的卡片列表。在卡片的一部分中,我放了一列并放了一个向下箭头按钮/图标。单击我想在扩展磁贴中打开更多详细信息。所以我为它创建了一个小部件功能。我注意到正在调用该函数,因为我在其中放置了打印件,但扩展磁贴并未在卡片正下方构建。
第一部分在这里构建我的动态卡片。
itemBuilder: (BuildContext ctxt, int index) {
return new Container(
margin: new EdgeInsets.fromLTRB(0, 10, 20, 0),
decoration: new BoxDecoration(
//color:Color.fromRGBO(255, 255,255, 1),
borderRadius: new BorderRadius.only(
topRight: const Radius.circular(35),
bottomRight: const Radius.circular(35)
),
),
width: double.infinity,
height: 55,
child:Card(
elevation: 5,
//color: Color.fromRGBO(255, 255, 255, 1),
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.only(
topRight: const Radius.circular(35),
bottomRight: const Radius.circular(35)
),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
width: 90,
child:
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
//new Row(
// mainAxisSize: MainAxisSize.max,
//children: <Widget>[
new Text(
"200", style: TextStyle(color:Colors.blue),
),
new Text(
"mmm", style: TextStyle(color:Colors.black),
),
// new Icon(Icons.account_circle)
//style: Theme.of(context).textTheme.body2
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
GestureDetector(
onTap: () {
print("Calling expansion tile");
expansionList(context,index);
},
child: Icon(Icons.arrow_drop_down),
)
]
)
//style: Theme.of(context).textTheme.body2
],
),
)
]
)
)
);
}
因此在 tap 函数上我称这个函数为 expansionList(context,index);我在下面显示了该功能的详细信息。但是磁贴没有打开。如何使磁贴在点击时动态打开。
Widget expansionList(BuildContext context, int index) {
print("In expansion tile");
return new ExpansionTile(
title: Text(
"TEST",
style: TextStyle(fontSize: 28.0),
),
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
//new Row(
// mainAxisSize: MainAxisSize.max,
//children: <Widget>[
new Text(
"200", style: TextStyle(color:Colors.blue),
),
new Text(
"mmm", style: TextStyle(color:Colors.black),
),
// new Icon(Icons.account_circle)
//style: Theme.of(context).textTheme.body2
],
),
]
);
}
最佳答案
您现在要做的是 - 每次点击您:
ExpansionTile 小部件的函数。但是您对返回值什么也不做,它甚至没有机会进入您的小部件树,它只是简单地构建而没有对其进行任何操作。
ExpansionTile 是一个小部件,包括:
3 个插槽,每个插槽可以容纳 Widget(或树):
leading - 通常你在这里放置头像/图标/复选框title - tile 的主要内容trailing - tile 的末尾,下拉箭头的最佳位置(默认包含在 ExpansionTile 中)和一个 children 数组 - 展开时显示的内容;
代码:
@override
Widget build(BuildContext context) {
return Container(
child: ListView.builder(itemBuilder: (BuildContext ctxt, int index) {
return new Container(
margin: new EdgeInsets.fromLTRB(0, 10, 20, 0),
decoration: new BoxDecoration(
//color:Color.fromRGBO(255, 255,255, 1),
borderRadius: new BorderRadius.only(
topRight: const Radius.circular(35),
bottomRight: const Radius.circular(35)),
),
width: double.infinity,
// height: 55,
child: Card(
elevation: 5,
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.only(
topRight: const Radius.circular(35),
bottomRight: const Radius.circular(35)),
),
child: expansionList(ctxt, index),
),
);
}),
);
}
如果您想自定义箭头,请将您想要的任何内容放在 leading 和 title 的折叠图 block 上 - 使用自定义 trailing。
Widget expansionList(BuildContext context, int index) {
print("Building expansion tile");
return new ExpansionTile(
initiallyExpanded: false,
leading: Icon(Icons.all_inclusive),
title: Column(
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text('Content'),
RaisedButton(
child: Text('Button'),
onPressed: () {},
),
Text('Row 1'),
],
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text('Content row 2'),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text('Content row 3')
],
)
],
),
children: <Widget>[
Image.network(
"https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-logo.png",
height: 55,
),
],
);
}
PS 熟悉代码格式化热键组合,并始终在末尾加上逗号 - 代码自动格式化会更好
关于点击时不会从卡片 ListView 中打开 Flutter Expansion Tile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55064341/
使用带有Rails插件的vim,您可以创建一个迁移文件,然后一次性打开该文件吗?textmate也可以这样吗? 最佳答案 你可以使用rails.vim然后做类似的事情::Rgeneratemigratonadd_foo_to_bar插件将打开迁移生成的文件,这正是您想要的。我不能代表textmate。 关于ruby-使用VimRails,您可以创建一个新的迁移文件并一次性打开它吗?,我们在StackOverflow上找到一个类似的问题: https://sta
设置:狂欢ruby1.9.2高线(1.6.13)描述:我已经相当习惯在其他一些项目中使用highline,但已经有几个月没有使用它了。现在,在Ruby1.9.2上全新安装时,它似乎不允许在同一行回答提示。所以以前我会看到类似的东西:require"highline/import"ask"Whatisyourfavoritecolor?"并得到:Whatisyourfavoritecolor?|现在我看到类似的东西:Whatisyourfavoritecolor?|竖线(|)符号是我的终端光标。知道为什么会发生这种变化吗? 最佳答案
我在我的Rails项目中使用Pow和powifygem。现在我尝试升级我的ruby版本(从1.9.3到2.0.0,我使用RVM)当我切换ruby版本、安装所有gem依赖项时,我通过运行railss并访问localhost:3000确保该应用程序正常运行以前,我通过使用pow访问http://my_app.dev来浏览我的应用程序。升级后,由于错误Bundler::RubyVersionMismatch:YourRubyversionis1.9.3,butyourGemfilespecified2.0.0,此url不起作用我尝试过的:重新创建pow应用程序重启pow服务器更新战俘
我有这个代码File.open(file_name,'r'){|file|file.read}但是Rubocop发出警告:Offenses:Style/SymbolProc:Pass&:readasargumenttoopeninsteadofablock.你是怎么做到的? 最佳答案 我刚刚创建了一个名为“t.txt”的文件,其中包含“Hello,World\n”。我们可以按如下方式阅读。File.open('t.txt','r',&:read)#=>"Hello,World\n"顺便说一下,由于第二个参数的默认值是'r',所以这样
我遇到了一个非常奇怪的问题,我很难解决。在我看来,我有一个与data-remote="true"和data-method="delete"的链接。当我单击该链接时,我可以看到对我的Rails服务器的DELETE请求。返回的JS代码会更改此链接的属性,其中包括href和data-method。再次单击此链接后,我的服务器收到了对新href的请求,但使用的是旧的data-method,即使我已将其从DELETE到POST(它仍然发送一个DELETE请求)。但是,如果我刷新页面,HTML与"new"HTML相同(随返回的JS发生变化),但它实际上发送了正确的请求类型。这就是这个问题令我困惑的
我正在为个人笔记创建一个日志应用程序,并且在我的Rakefile中包含以下内容:task:newdoentry_name="Entries/#{Time.now.to_s.gsub(/[-\:]+/,'.').gsub(/.0500+/,'')}.md"`touch#{entry_name}``echo"#$(date)">>#{entry_name}`end我想包括的最后一部分是Vim文本编辑器的打开,但我不知道如何打开它,就像我直接从bash终端调用它一样。我试过:vim#{entry_name}但不幸的是,我认为它们都将其作为后台进程打开。我一直在引用“6WaystoRunShe
我有可变数量的表格和可变数量的行,我想让它们一个接一个地显示,但如果表格不适合当前页面,请将其放在下一页,然后继续。我已将表格放入事务中,以便我可以回滚然后打印它(如果高度适合当前页面),但我如何获得表格高度?我现在有这段代码pdf.transactiondopdf.table@data,:font_size=>12,:border_style=>:grid,:horizontal_padding=>10,:vertical_padding=>3,:border_width=>2,:position=>:left,:row_colors=>["FFFFFF","DDDDDD"]pdf.
我要下载http://foobar.com/song.mp3作为song.mp3,而不是让Chrome在其native中打开它浏览器中的播放器。我怎样才能做到这一点? 最佳答案 您只需要确保发送这些header:Content-Disposition:attachment;filename=song.mp3;Content-Type:application/octet-streamContent-Transfer-Encoding:binarysend_file方法为您完成:get'/:file'do|file|file=File.
我使用“newapp_name”创建了一个新的Rails应用程序,我正在尝试编辑.gitignore文件,但在我的应用程序文件夹中找不到它。我在哪里可以找到它?我安装了Git。 最佳答案 .gitignore位于项目的root中,而不是app子目录中。首先打开终端并进入您的目录。您需要使用ls-a来显示stash文件。然后使用打开.gitignore 关于ruby-on-rails-尝试打开.gitignore以在文本编辑器中对其进行编辑,但在OSXMountainLion上找不到文件位
我是Ruby的新手,我正在尝试以如下方式打开文件:#!/usr/bin/envrubydata_file='~/path/to/file.txt'file=File.open(data_file,'r')但是我得到“没有这样的文件或目录”(该文件确实存在于该目录中)。如果我将该文件路径作为命令行参数,它会起作用,例如:#!/usr/bin/envrubyfile=File.open(ARGV[0],'r')然后从命令行运行,如:rubyscript.cgi~/path/to/file.txt关于如何让它以第一种方式工作的任何想法? 最佳答案