首页 > 解决方案 > 将长文本紧紧包裹在容器周围

问题描述

如何将长文本紧紧包裹在容器周围。MS word 有一个紧凑的包装功能。我需要将我的文本包裹在底部容器周围,使其看起来像上传的图像。

Stack(
      alignment: Alignment.topRight,
      children: [
        Padding(
          padding: EdgeInsets.only(bottom: 4, left: 4),
          child: Container(
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(12),
                color: Color.fromRGBO(249, 249, 249, 1),
                // color: Colors.white,
                boxShadow: [
                  BoxShadow(
                    color: Colors.black.withOpacity(0.10),
                    spreadRadius: 1,
                    blurRadius: 5,
                    offset: Offset(3, 3),
                  )
                ]),
            child: Padding(
              padding: const EdgeInsets.symmetric(horizontal: 8.0),
              child: Column(
                children: [
                  Text(
                    "we pay close attention to every detail",
                    style: TextStyle(),
                    textAlign: TextAlign.right,
                  ),
                  Container(
                    alignment: Alignment.topRight,
                    child: new Text(
                      "A really long text",
                      style: TextStyle(),
                      overflow: TextOverflow.fade,
                      textAlign: TextAlign.right,
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
        Positioned(
          bottom: 0,
          left: 0,
          child: Container(
            height: 48,
            width: 48,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(12),
              color: Color.fromRGBO(196, 196, 196, 1),
              // color: Colors.white,
            ),
          ),
        )
      ],
    );

我得到的输出是:

我的输出

我需要这样的输出:

所需输出

标签: flutterflutter-web

解决方案


也许这个包可以帮助你drop_cap_text

DropCapText(
loremIpsumText,
style: TextStyle(
    height: 1.3,
    fontFamily: 'times',
),
dropCapChars: 2,
indentation: Offset(25, 10),
),

推荐阅读