admin管理员组

文章数量:1417555

How to wrap text around the Icon as the text will drop under the icon as its height is more than that of the icon. In the below image, text should be under the icon from fourth line

I've tried wrapping it Expanded and Flex, Better if no hard coded customizations.

How to wrap text around the Icon as the text will drop under the icon as its height is more than that of the icon. In the below image, text should be under the icon from fourth line

I've tried wrapping it Expanded and Flex, Better if no hard coded customizations.

Share Improve this question asked Jan 31 at 9:31 ShanuShanu 6671 gold badge5 silver badges28 bronze badges 2
  • 2 It's more involved that it seems. I recommend having a look at the pub.dev package: float_column. – Dan R Commented Jan 31 at 9:57
  • Assuming the text data won't be coming from API, A workaround would be to use Stack widget and add many empty text "" before the lorem ipsum string. Would you like the code for it? – Ali Jawad Commented Jan 31 at 15:29
Add a comment  | 

2 Answers 2

Reset to default 1

I believe you are looking for something similar to CSS's float. There is a package called float_column. This should solve your issue, implement it as such:

FloatColumn(
  children: [
    const Floatable(
      float: FCFloat.start,
      child: Icon(
        Icons.info,
        size: 50.0,
      )
    ),
    WrappableText(text: TextSpan(text: loremIpsum))
  ],
),

In the example, your icon will be included inside the floatable widget, which is provided by the package itself. Your text should be wrapped by the WrappableText widget. Also don't fet to set the float parameter to the Floatable widget as per your need, your example requires the FCFloat.start. The result will be:

checkout drop_cap_text package here is the demo enter image description here

DropCapText(
    loremIpsumText,
    dropCap: DropCap(
    width: 100,
    height: 100,
    child: Imagework(
        'https://www.codemate/wp-content/uploads/2017/09/flutter-logo.png')
    ),
),

本文标签: flutterHow to wrap text around a widgetStack Overflow