mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-07-15 03:04:25 +08:00
refactor(整理richText的说明):
This commit is contained in:
@ -19,8 +19,8 @@ class _Demo extends State<SnackBarActionDemo> {
|
|||||||
return new Center(
|
return new Center(
|
||||||
child: new Column(
|
child: new Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new GestureDetector(
|
new RaisedButton(
|
||||||
onTap: () {
|
onPressed: () {
|
||||||
final snackBar = new SnackBar(
|
final snackBar = new SnackBar(
|
||||||
content: new Text('这是一个SnackBar, 右侧有SnackBarAction, 3秒后消失'),
|
content: new Text('这是一个SnackBar, 右侧有SnackBarAction, 3秒后消失'),
|
||||||
backgroundColor:Color(0xffc91b3a),
|
backgroundColor:Color(0xffc91b3a),
|
||||||
@ -39,8 +39,8 @@ class _Demo extends State<SnackBarActionDemo> {
|
|||||||
|
|
||||||
child: new Text('点我显示有action的SnackBar'),
|
child: new Text('点我显示有action的SnackBar'),
|
||||||
),
|
),
|
||||||
new GestureDetector(
|
new RaisedButton(
|
||||||
onTap: () async {
|
onPressed: () async {
|
||||||
final snackBar = new SnackBar(
|
final snackBar = new SnackBar(
|
||||||
content: new Text('右侧无SnackBarAction, 3秒后消失'),
|
content: new Text('右侧无SnackBarAction, 3秒后消失'),
|
||||||
backgroundColor:Color(0xffc91b3a),
|
backgroundColor:Color(0xffc91b3a),
|
||||||
|
@ -11,33 +11,13 @@ const String intro = """
|
|||||||
|
|
||||||
无论是Text或者Text.rich, 查看源代码发现. 都是由RichText构建出来
|
无论是Text或者Text.rich, 查看源代码发现. 都是由RichText构建出来
|
||||||
|
|
||||||
RichText的源码展示
|
|
||||||
|
|
||||||
```
|
### **基本用法**
|
||||||
// Text 源码
|
我们可以让一段文本通过使用不同的TextSpan显示不同的样式。比如我们让"Hello beautiful world"的每个单词都显示不同的样式.
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
...
|
|
||||||
Widget result = RichText(
|
|
||||||
...
|
|
||||||
|
|
||||||
style: effectiveTextStyle,
|
|
||||||
text: data,
|
|
||||||
children: textSpan != null ? <TextSpan>[textSpan] : null,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
...
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
### **基本实例**
|
|
||||||
|
|
||||||
""";
|
""";
|
||||||
const String diff = """
|
|
||||||
|
|
||||||
|
|
||||||
""";
|
|
||||||
|
|
||||||
class Demo extends StatefulWidget {
|
class Demo extends StatefulWidget {
|
||||||
static const String routeName = '/element/Form/Text/RichText';
|
static const String routeName = '/element/Form/Text/RichText';
|
||||||
_Demo createState() => _Demo();
|
_Demo createState() => _Demo();
|
||||||
|
Reference in New Issue
Block a user