Improve TextSpan
Now we just have one TextSpan class that handles both simple strings, trees of children, and styling both. This approach simplifies the interface for most clients. This patch also removes StyledText, which was weakly typed and tricky to use correctly. The replacement is RichText, which is strongly typed and uses TextSpan.
This commit is contained in:
@@ -34,9 +34,24 @@ final TextStyle _kUnderline = const TextStyle(
|
||||
|
||||
Widget toStyledText(String name, String text) {
|
||||
TextStyle lineStyle = (name == "Dave") ? _kDaveStyle : _kHalStyle;
|
||||
return new StyledText(
|
||||
return new RichText(
|
||||
key: new Key(text),
|
||||
elements: [lineStyle, [_kBold, [_kUnderline, name], ":"], text]
|
||||
text: new TextSpan(
|
||||
style: lineStyle,
|
||||
children: <TextSpan>[
|
||||
new TextSpan(
|
||||
style: _kBold,
|
||||
children: <TextSpan>[
|
||||
new TextSpan(
|
||||
style: _kUnderline,
|
||||
text: name
|
||||
),
|
||||
new TextSpan(text: ':')
|
||||
]
|
||||
),
|
||||
new TextSpan(text: text)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user