getStyledTexts method

List<TextSpan> getStyledTexts(
  1. BuildContext context
)

Implementation

List<TextSpan> getStyledTexts(BuildContext context) {
  final List<TextSpan> result = [];
  final style = TextStyle(color: Colors.grey, fontSize: 15);

  final startText = autoCompleteItem.text?.substring(0, autoCompleteItem.offset);
  if (startText?.isNotEmpty == true) {
    result.add(TextSpan(text: startText, style: style));
  }

  final boldText =
      autoCompleteItem.text?.substring(autoCompleteItem.offset!, autoCompleteItem.offset! + autoCompleteItem.length!);
  result.add(
    TextSpan(text: boldText, style: style.copyWith(color: Theme.of(context).textTheme.bodyText1?.color)),
  );

  final remainingText = autoCompleteItem.text?.substring(autoCompleteItem.offset! + autoCompleteItem.length!);
  result.add(TextSpan(text: remainingText, style: style));

  return result;
}