小编Wei*_*ong的帖子

Flutter是否支持负保证金?

通常不需要负边距,但有些情况下它确实很有用.例如:为什么要使用负边距?

现在,当我将容器的边距设置为负值时,我收到以下错误:

I/flutter ( 3173): 'package:flutter/src/widgets/container.dart': Failed assertion: line 251: 'margin == null ||
I/flutter ( 3173): margin.isNonNegative': is not true.
Run Code Online (Sandbox Code Playgroud)

flutter

18
推荐指数
7
解决办法
7135
查看次数

有没有一种简单的方法可以在Flutter测试中找到从RichText构建的特定文本?

例如,我可能在当前的小部件树中有一个RichText,看起来像

new RichText(
 text: new TextSpan(
   text: 'Hello ',
   style: DefaultTextStyle.of(context).style,
   children: <TextSpan>[
     new TextSpan(text: 'bold', style: new TextStyle(fontWeight: FontWeight.bold)),
     new TextSpan(text: ' world!'),
   ],
 ),
)
Run Code Online (Sandbox Code Playgroud)

我尝试使用,find.text('Hello bold world!')但因为它不是文本,所以无法使用。

flutter

4
推荐指数
3
解决办法
261
查看次数

如何设置Text或RichText的最大行数?

在android中,我们可以为文本视图设置最大行数,如下所示:

<TextView
    android:id="@+id/text"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"  
    android:maxLines="5" />
Run Code Online (Sandbox Code Playgroud)

但是在颤动中,我们可以通过添加最大高度限制来做到这一点,但是我们需要知道确切的高度是多少。

有什么方法可以轻松指定Text / RichText的最大行数?

flutter

3
推荐指数
3
解决办法
2624
查看次数

标签 统计

flutter ×3