如何在Flutter中删除图像和文本之间的空间

时间:2018-10-10 08:56:57

标签: flutter flutter-layout

我想在图像(fb图标)正下方显示文本(Facebook),且不留任何间距。下面是到目前为止的代码:


     * @param tryTimeout
     *      Indicates the maximum time allowed for any single try of an HTTP request. A value of {@code null} means that
     *      you accept our default. NOTE: When transferring large amounts of data, the default TryTimeout will probably
     *      not be sufficient. You should override this value based on the bandwidth available to the host machine and
     *      proximity to the Storage service. A good starting point may be something like (60 seconds per MB of
     *      anticipated-payload-size).

目前,我看到了这种情况,并希望删除图像和文本之间的空间。

enter image description here

2 个答案:

答案 0 :(得分:2)

Image(
  image: AssetImage("assets/fb_icon.png"),
),
Text('Facebook.',
    style: TextStyle(
      fontStyle: FontStyle.italic,
      color: Colors.white,))

在这种情况下,必须没有填充。您可以通过以下方式精确检查png文件中的填充:

Image(
  image: AssetImage("assets/fb_icon.png"),
  color: Colors.red,
  colorBlendMode: BlendMode.multiply,
),

这将显示图像的真实边框

答案 1 :(得分:0)

实际上,您应该使用BoxFit.cover来查看效果,因为图像的物理高度小于为其分配的高度。

这是解决方案

       Image(
          image: AssetImage("assets/fb_icon.png"),
          width: 180.0,
          height: 250.0,
          fit: BoxFit.cover,
        ),

您可以尝试其他BoxFit,看看哪种更适合您。

相关问题