I am trying to fetch the text(Calories) from the below widget.
return Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Flexible(
child: AutoSizeText.rich(
TextSpan(
children: <TextSpan>[
TextSpan(
text: NumberFormat.decimalPattern(locale).format(
calories!.round(),
),
),
// reduce spacing between amount and unit as defined in design
TextSpan(text: ' ', style: TextStyle(letterSpacing: -5.0)),
TextSpan(
text: _translate(AppLocalization.Caloriesunitkcal),
style: Theme.of(context)
.textTheme
.bodyText1!
.copyWith(color: caloriesTextColor),
)
],
),
maxLines: 1,
minFontSize: AdTheme.smallestUsedTextSize,
group: _group1,
style: Theme.of(context)
.textTheme
.headline3!
.copyWith(color: caloriesTextColor),
),
),
],
),
AutoSizeText(
description!,
maxLines: 1,
textAlign: TextAlign.center,
minFontSize: AdTheme.smallestUsedTextSize,
group: _group2,
style: Theme.of(context).textTheme.bodyText1,
)
],
);
}
The solution I tried to fetch the textspan is as below:
var firstCell = find
.descendant(
of: find.byType(Flexible),
matching: find.byType(TextSpan),
)
.evaluate()
.whereType<Text>()
.first;
print(firstCell.data);
But this solution isnt allowing me to fetch the text in this text span.
Kindly help if someone has some insights on the same and has worked with fething similar kind of data.