如何在flutter中将文本环绕在svg周围?

问题描述 投票:0回答:1

所以我有一个 svg 和一些多行文本,我想水平对齐,但问题是下一行文本应该覆盖 svg 的底部区域,如何在 flutter 中做到这一点?

我已经尝试过这个:

Padding(
                padding: const EdgeInsets.only(
                    left: 16.0, right: 16, bottom: 16),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    SvgPicture.asset(ImageConstant.verifiedMarker),
                    Expanded(
                      child: Text(
                        trip.formattedAddress,
                        softWrap: true,
                        textAlign: TextAlign.start,
                        style:
                            theme.textTheme.bodyMedium?.copyWith(height: 1.5),
                      ),
                    ),
                  ],
                ),
              ),

enter image description here

flutter svg
1个回答
0
投票

试试这个

Padding(
    padding: const EdgeInsets.all(16.0),
    child: RichText(
      text: TextSpan(
        children: [
          WidgetSpan(
            alignment: PlaceholderAlignment.middle,
            child: SvgPicture.asset(
              'assets/icon.svg', 
              width: 20, 
              height: 20,
            ),
          ),
         TextSpan(
            text:
                "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
            style: TextStyle(fontSize: 16, color: Colors.black),
          ),
        ],
      ),
    ),
  )

输出:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.