Reputation: 431
I have a list of TextSpan that I have initialize to an empty list and later I add TextSpan to it if a certain condition is met.
List<TextSpan> _textSpan = [];
if(text.contains("*")){
_textSpan.add(TextSpan( text: text), style: TextStyle(fontWeight: FontWeight.w400))
} else if (){
.
.
.
}
Later I return :
AutoSizeText.rich(
TextSpan(
children: _textSpan,
Style: TextStyle(),
))
My question is How can I create a function that I will be able to wrap children: _textSpan
to children: funct(_textSpan)
I have tried:
function(List<TextSpan> StextSpan){
...
}
Upvotes: 0
Views: 158
Reputation: 12673
Does this work for You?
List<TextSpan> function(List<TextSpan> x){
//Do what You want to do with x
return x;
}
Then do:
children: function(_textSpan)
Upvotes: 1