如何在Flutter中将文本小部件浮动在图像小部件周围

时间:2019-04-01 10:32:17

标签: dart flutter

enter image description here

如何在颤振中达到效果?有例子吗?

3 个答案:

答案 0 :(得分:3)

您可以使用drop_cap_text库来获得此行为。用法是这样的:

'always'

this

或者您可以像在库中一样将SizedBoxRichText混合并匹配,以自己尝试。

答案 1 :(得分:0)

非常简单,您不需要使用该库。

 // Replace IconSVG with image of you.
 RichText(
          text: TextSpan(
          children: [
                      WidgetSpan(
                        child: IconSVG(
                             IconSVGPath.ic_suggest, 30, 30, null),
                          ),
                      TextSpan(text: " Tùy chọn các nội dung dưới đây để thay đổi giao diện CV phù hợp với bản thân bạn.",
                                  style: TextStyle(color: HexColor(
                                      StringColors.color_orange_primary),
                                      fontSize: 16,
                                      fontWeight: FontWeight.w400,
                                      fontFamily: NUNITO_SANS),
                                ),
            ],
            style: TextStyle(color: Colors.red,)
      ),

结果将如下所示: flutter

答案 2 :(得分:0)

flutter 有一个新的 float_column 库支持此功能:

example screenshot

用这样的代码:

FloatColumn(
  children: [
    const Floatable(float: FCFloat.start, child: DropCap('“T', size: 3)),
    Floatable(
      float: FCFloat.end,
      clear: FCClear.start,
      clearMinSpacing: 12,
      maxWidthPercentage: 0.333,
      padding: EdgeInsetsDirectional.only(start: 8),
      child: Img(
        assetName: _name('jeremy-bishop-EwKXn5CapA4-unsplash.jpg'),
        title: 'Photo by Jeremy Bishop on Unsplash',
      ),
    ),
    Floatable(
      float: FCFloat.start,
      clear: FCClear.start,
      clearMinSpacing: 175,
      maxWidthPercentage: 0.25,
      padding: EdgeInsetsDirectional.only(end: 12),
      child: Img(
        assetName: _name('walt_whitman.jpg'),
        title: 'Walt Whitman',
      ),
    ),
    WrappableText(text: _text),
  ],
)

您可以在此处查看完整的示例代码:basic_ltr.dart