简体   繁体   English

为什么我的 Stack 剪裁了图像的右侧?

[英]Why is my Stack clipping the right-hand side of images?

I want to put some text over an image and I thought of using a ClipRRect with a Stack as a child.我想在图像上放一些文本,我想在小时候使用带有堆栈的 ClipRRect。 That way I could stack the images and text on top of each other.这样我就可以将图像和文本堆叠在一起。 When I do this though, the image gets cut off on the right-hand side.但是,当我这样做时,图像会在右侧被切断。 Can anyone point out the problem?任何人都可以指出问题吗?

Link here as I cannot embed images yet在这里链接,因为我还不能嵌入图像

return ClipRRect(
  borderRadius: BorderRadius.circular(8.0),
  child: Stack(
    children:<Widget>[
      Image.network(
        listItem.imageUrl,
        height: 200.0,
        //width: 100.0,
        fit: BoxFit.cover
      ),
    ]
  ),
);

The reason why the right side of the image is clipped out is that you are placing a rounding the border of the Stack instead of the Image.图像右侧被剪掉的原因是您放置的是堆栈的边框而不是图像。 This is how you can achieve what you've wanted to do:这是您实现您想做的事情的方法:

return Stack(
    children:<Widget>[
      ClipRRect(
        borderRadius: BorderRadius.circular(8.0),
        child: Image.network(
        listItem.imageUrl,
         height: 200.0,
         fit: BoxFit.cover
        ),
       ),
       Align(alignment:Alignment.bottomCenter,child:Text("Hello World")),
    ]
);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 'bool' 类型的值? 不能分配给“bool”类型的变量。 尝试更改变量的类型,或将右侧类型转换为“bool” - value of type 'bool?' can't be assigned to a variable of type 'bool'. Try changing the type of the variable, or casting the right-hand type to 'bool' Dart / Flutter列表中的左侧,右侧编译器错误 - Left Hand Side , Right Hand Side Compiler Errors in Dart / Flutter List 如何在 Flutter App 的文本域右侧添加美元符号 - How to Add Dollar Sign on the RIght hand Side of the Textfield in Flutter App 如何从 dartz 只获得右手边的值? - How to obtain only the right hand side value from dartz? 右对齐消息时间戳与颤动消息文本字段的尾随右侧 - Right aligning message timestamp with trailing right-hand-side of flutter message text field 是否有任何类似的小部件或 function 从 flutter 的右侧从屏幕上弹出的“showModelBottomSheet”? - Is there any similar widget or function like 'showModelBottomSheet' that pop on screen from right hand side in flutter? TextField 的后缀是不是意味着将小部件放在 TextField 的右侧? - Isn't TextField's suffix means putting widget at the right hand side of TextField? 为什么我的 Flutter Inspector 面板不能像其他工具一样停靠在 IDE 的右侧? - Why won't my Flutter Inspector panel dock to the right side of the IDE like the other tools? 在扑中使用png剪切图像? - Clipping images using png in flutter? 列内堆栈的抖动裁剪问题 - Flutter clipping issue with Stack inside of Column
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM