它切断了我的背景渐变并且不显示图像。
我需要一个 flutter 布局,左边是一列文本对象,右边是图像。我在 flutter.io 网站上找到了一张示例图片,但他们没有显示这个特定示例的代码。我对数据列进行了格式化,但无法弄清楚如何将图像添加到右侧。
这是我试图明智布局的图片。
这是我现有的代码,在图像右侧包含我们想要的数据
class MemberProfile extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: LBAppBar().getAppBar(),
drawer: LBDrawer().getDrawer(),
body:
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color.fromRGBO(1, 89, 99, 1.0), Colors.grey],
begin: Alignment.bottomLeft,
end: Alignment.topRight,
),
),
child:
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: EdgeInsets.only(top: 10.0, bottom: 10.0, left: 20.0),
child: Text("Name : Sam Cromer",
style: TextStyle(
color: Colors.white70,
fontWeight: FontWeight.bold,
fontSize: 19.0)),
),
Container(
margin: EdgeInsets.only(top: 10.0, bottom: 10.0, left: 20.0),
child: Text("Sex : Male",
style: TextStyle(
color: Colors.white70,
fontWeight: FontWeight.bold,
fontSize: 19.0))),
Container(
margin: EdgeInsets.only(top: 10.0, bottom: 10.0, left: 20.0),
child: Text("Age : 42",
style: TextStyle(
color: Colors.white70,
fontWeight: FontWeight.bold,
fontSize: 19.0))),
Container(
margin: EdgeInsets.only(top: 10.0, bottom: 10.0, left: 20.0),
child: Text("Status : Divorced",
style: TextStyle(
color: Colors.white70,
fontWeight: FontWeight.bold,
fontSize: 19.0))),
Container(
margin: EdgeInsets.only(top: 10.0, bottom: 10.0, left: 20.0),
child: Text("Trumatic Event : ",
style: TextStyle(
color: Colors.white70,
fontWeight: FontWeight.bold,
fontSize: 19.0))),
Container(
margin: EdgeInsets.only(top: 10.0, bottom: 10.0, left: 20.0),
child: Text("Motorcycle Accident July 2005, TBI",
style: TextStyle(
color: Colors.white70,
fontWeight: FontWeight.bold,
fontSize: 19.0))),
Container(
margin: EdgeInsets.only(top: 10.0, bottom: 10.0, left: 20.0),
child: Text("Bio :",
style: TextStyle(
color: Colors.white70,
fontWeight: FontWeight.bold,
fontSize: 19.0))),
Container(
margin: EdgeInsets.only(
left: 30.0, top: 150.0, bottom: 30.0, right: 30.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
margin: EdgeInsets.all(20.0),
child: OutlineButton(
child: Text('Offer support'),
textColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0)),
onPressed: () {
// Navigator.of(context).push( MaterialPageRoute(builder: (BuildContext context) => CheckInQ()));
},
),
)
],
),
)
],
),
),
//here
),
);
}
}
最佳答案
这是您的 MemberProfile 类,已修改为包含如上图所示布局的一个自定义行:
class MemberProfile extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color.fromRGBO(1, 89, 99, 1.0), Colors.grey],
begin: Alignment.bottomLeft,
end: Alignment.topRight,
),
),
width: MediaQuery.of(context).size.width,
height: 200.0,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget> [
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Name : Sam Cromer",
style: TextStyle(
color: Colors.white70,
fontWeight: FontWeight.bold,
fontSize: 19.0)),
Text("Sex : Male",
style: TextStyle(
color: Colors.white70,
fontWeight: FontWeight.bold,
fontSize: 19.0)),
Text("Age : 42",
style: TextStyle(
color: Colors.white70,
fontWeight: FontWeight.bold,
fontSize: 19.0)),
Text("Status : Divorced",
style: TextStyle(
color: Colors.white70,
fontWeight: FontWeight.bold,
fontSize: 19.0)),
Text("Trumatic Event : ",
style: TextStyle(
color: Colors.white70,
fontWeight: FontWeight.bold,
fontSize: 19.0)),
Text("Motorcycle ",
style: TextStyle(
color: Colors.white70,
fontWeight: FontWeight.bold,
fontSize: 19.0)),
Text("Bio :",
style: TextStyle(
color: Colors.white70,
fontWeight: FontWeight.bold,
fontSize: 19.0)),
],
),
Column(
children: <Widget>[
SizedBox(
width: 200.0,
height: 200.0,
child: Image.asset('assets/images/test.jpg'), // Your image widget here
),
],
),
]
),
),
);
}
此处给出的代码将行的高度限制为200.0,因此图像的大小不会扭曲行的总体布局,您可以选择另一种方法是将 Image 小部件放入具有固定 width 和 height 的 SizedBox。
gradient 被cut off 的原因是因为它被definition 应用于父级Container 和容器中。 “根据 child 的大小调整自己”,所以如果你想让你的“渐变效果”填满整个屏幕,你必须设置明确的 width 和 height:
body:
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
关于dart - 有 2 个 child 的行,一列和一个图像布局在 flutter 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54725769/
是否可以为特定(或所有)项目使用多个布局?例如,我有几个项目,我想对其应用两种不同的布局。一个是绿色的,一个是蓝色的(但是)。我想将它们编译到我的输出目录中的两个不同文件夹中(例如v1和v2)。我一直在玩弄规则和编译block,但我不知道这是怎么回事。因为,每个项目在编译过程中只编译一次,我不能告诉nanoc第一次用layout1编译,第二次用layout2编译。我试过这样的东西,但它导致输出文件损坏。compile'*'doifitem.binary?#don’tfilterbinaryitemselsefilter:erblayout'layout1'layout'layout2'
我有带有Logo图像的公司模型has_attached_file:logo我用他们的Logo创建了许多公司。现在,我需要添加新样式has_attached_file:logo,:styles=>{:small=>"30x15>",:medium=>"155x85>"}我是否应该重新上传所有旧数据以重新生成新样式?我不这么认为……或者有什么rake任务可以重新生成样式吗? 最佳答案 参见Thumbnail-Generation.如果rake任务不适合你,你应该能够在控制台中使用一个片段来调用重新处理!关于相关公司
我正在尝试使用Ruby2.0.0和Rails4.0.0提供的API从imgur中提取图像。我已尝试按照Ruby2.0.0文档中列出的各种方式构建http请求,但均无济于事。代码如下:require'net/http'require'net/https'defimgurheaders={"Authorization"=>"Client-ID"+my_client_id}path="/3/gallery/image/#{img_id}.json"uri=URI("https://api.imgur.com"+path)request,data=Net::HTTP::Get.new(path
2022/8/4更新支持加入水印水印必须包含透明图像,并且水印图像大小要等于原图像的大小pythonconvert_image_to_video.py-f30-mwatermark.pngim_dirout.mkv2022/6/21更新让命令行参数更加易用新的命令行使用方法pythonconvert_image_to_video.py-f30im_dirout.mkvFFMPEG命令行转换一组JPG图像到视频时,是将这组图像视为MJPG流。我需要转换一组PNG图像到视频,FFMPEG就不认了。pyav内置了ffmpeg库,不需要系统带有ffmpeg工具因此我使用ffmpeg的python包装p
有这样的事吗?我想在Ruby程序中使用它。 最佳答案 试试这个http://csl.sublevel3.org/jp2a/此外,Imagemagick可能还有一些东西 关于ruby-是否有将图像文件转换为ASCII艺术的命令行程序或库?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/6510445/
我正在使用Dragonfly在Rails3.1应用程序上处理图像。我正在努力通过url将图像分配给模型。我有一个很好的表格:{:multipart=>true}do|f|%>RemovePicture?Dragonfly的文档指出:Dragonfly提供了一个直接从url分配的访问器:@album.cover_image_url='http://some.url/file.jpg'但是当我在控制台中尝试时:=>#ruby-1.9.2-p290>picture.image_url="http://i.imgur.com/QQiMz.jpg"=>"http://i.imgur.com/QQ
我对图像处理完全陌生。我对JPEG内部是什么以及它是如何工作一无所知。我想知道,是否可以在某处找到执行以下简单操作的ruby代码:打开jpeg文件。遍历每个像素并将其颜色设置为fx绿色。将结果写入另一个文件。我对如何使用ruby-vips库实现这一点特别感兴趣https://github.com/ender672/ruby-vips我的目标-学习如何使用ruby-vips执行基本的图像处理操作(Gamma校正、亮度、色调……)任何指向比“helloworld”更复杂的工作示例的链接——比如ruby-vips的github页面上的链接,我们将不胜感激!如果有ruby-
Organization和Image具有一对一的关系。Image有一个名为filename的列,它存储文件的路径。我在Assets管道中包含这样一个文件:app/assets/other/image.jpg。播种时如何包含此文件的路径?我已经在我的种子文件中尝试过:@organization=...@organization.image.create!(filename:File.open('app/assets/other/image.jpg'))#Ialsotried:#@organization.image.create!(filename:'app/assets/other/i
默认情况下:回形针gem将所有附件存储在公共(public)目录中。出于安全原因,我不想将附件存储在公共(public)目录中,所以我将它们保存在应用程序根目录的uploads目录中:classPost我没有指定url选项,因为我不希望每个图像附件都有一个url。如果指定了url:那么拥有该url的任何人都可以访问该图像。这是不安全的。在user#show页面中:我想实际显示图像。如果我使用所有回形针默认设置,那么我可以这样做,因为图像将在公共(public)目录中并且图像将具有一个url:Someimage:看来,如果我将图像附件保存在公共(public)目录之外并且不指定url(同
使用Paperclip,我想从这样的URL抓取图像:require'open-uri'user.photo=open(url)问题是我最后得到一个像“open-uri20110915-4852-1o7k5uw”这样的文件名。有什么方法可以更改user.photo上的文件名?作为一个额外的变化,Paperclip将我的文件存储在S3上,所以如果我可以在初始分配中设置我想要的文件名就更好了,这样图像就会上传到正确的S3key。像这样:user.photo=open(url),:filename=>URI.parse(url).path 最佳答案