首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有两个文本小部件的颤振行小部件不相互跟踪

问带有两个文本小部件的颤振行小部件不相互跟踪
EN

Stack Overflow用户
提问于 2022-09-02 06:34:42
回答 3查看 58关注 0票数 0

我试图在行小部件中包装文本(多行),然后是"Read More“。

Lorem Ipsum只是印刷和排版行业的虚拟文本。自从1500年代以来,Lorem就一直是业界标准的虚拟文本,当时一台不知名的打印机拿出一台打字机,把它拼成一本样书。读了更多.

我尝试使用行小部件(阅读更多),它已经溢出到下一行。

只想显示可读的文本,后面跟着内容,而不溢出到下一行。单击“阅读更多”,我将显示底部模型表。

请帮忙..。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2022-09-02 06:53:38

您可以使用RichText而不是Row

代码语言:javascript
复制
RichText(
                text: TextSpan(
                  style: TextStyle(color: Colors.black),
                  children: <TextSpan>[
                    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.",
                    ),
                    TextSpan(
                      text: 'Read more!',
                      style: TextStyle(fontWeight: FontWeight.bold),
                      recognizer: TapGestureRecognizer()
                        ..onTap = () {
                          print('Read more click');
                          // what you wnat when click more
                        },
                    ),
                  ],
                ),
              ),

​

​

票数 1
EN

Stack Overflow用户

发布于 2022-09-02 06:38:42

为此,您可以使用雷德莫尔包。

代码语言:javascript
复制
ReadMoreText(
  "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.",
  trimLines: 2,
  colorClickableText: Colors.pink,
  trimMode: TrimMode.Line,
  trimCollapsedText: 'Show more',
  trimExpandedText: 'Show less',
  moreStyle: TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
);
票数 0
EN

Stack Overflow用户

发布于 2022-09-02 06:50:19

要做到这一点,只需添加一个包readmore: ^2.1.0。

在.dart文件中导入import 'package:readmore/readmore.dart';

使用此代码可自动调整容器高度。

代码语言:javascript
复制
Container(
                        margin: const EdgeInsets.only(
                          top: 30,
                          left: 10,
                          right: 10,
                          bottom: 40.0,
                        ),
                        color: Colors.transparent,
                        child: ReadMoreText(
                          'your_text',
                          trimLines: 4,
                          colorClickableText: Colors.pink,
                          trimMode: TrimMode.Line,
                          trimCollapsedText: 'Show more',
                          postDataTextStyle: TextStyle(
                            color: Colors.blue,
                          ),
                          style: TextStyle(
                            fontFamily: 'Avenir',
                            color: Colors.black,
                          ),
                          trimExpandedText: 'Show less',
                          lessStyle: TextStyle(
                            fontFamily: 'Avenir',
                            fontSize: 16.0,
                            fontWeight: FontWeight.bold,
                            color: Colors.blue,
                          ),
                          moreStyle: TextStyle(
                            fontSize: 16,
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                        width: MediaQuery.of(context).size.width,
                      ),
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73578640

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档