简体   繁体   English

Flutter 文本溢出带有边框半径的父容器

[英]Flutter Text overflows parent container with border radius

I created a parent container with border radius circular but the text does not follow the same and overflows the container on the bottom left.How to make the text adjust to parent container?我创建了一个边界半径为圆形的父容器,但文本不遵循相同的规则并溢出了左下角的容器。如何使文本调整到父容器? 在此处输入图像描述

Just add some padding using the padding parameter in your container and you are good to go!只需使用容器中的 padding 参数添加一些填充,就可以了!

Container(padding: EdgeInsets.all(10),)

You'll find everything about it here.你会在这里找到关于它的一切。

use the property clipBehavior and set it to Clip.antiAlias like the example below使用属性 clipBehavior 并将其设置为 Clip.antiAlias 如下例所示

Container(
      margin: EdgeInsets.only(left: 10, right: 10),
      clipBehavior: Clip.antiAlias,
      decoration: BoxDecoration(
        color: Colors.red,
        borderRadius: const BorderRadius.all(Radius.circular(10)),
        boxShadow: [
          BoxShadow(
            color: Colors.black26,
            blurRadius: 6,
            offset: const Offset(0, 3),
          ),
        ],
        child: Container(
        colors: Colors.amber,
        child:Text('hello world'),
       ),
      ),

Just your text to new container and give the height and width to it, and do not to forget to change overflow property in Text widget.只需将您的文本添加到新容器并为其指定高度和宽度,并且不要忘记更改文本小部件中的溢出属性。 You can also wrap these widgets in to FittedBox, to size text to the container.您还可以将这些小部件包装到 FittedBox 中,以根据容器调整文本大小。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM