getFootEndNote method
Function for getting Foot and End notes
Implementation
RichText getFootEndNote(FootEndNote footEndNote, List<Styles> stylesList, String refNo) {
TextStyle textStyle = const TextStyle(inherit: false);
String tempSpanText = "$refNo ${footEndNote.text}";
bool superScript = false;
bool subScript = false;
if (footEndNote.pStyle.isNotEmpty) {
Styles? textStyles = stylesList.firstWhereOrNull((style) {
return style.styleId == footEndNote.pStyle;
});
if (textStyles != null) {
if (textStyles.fontSize != 0) {
textStyle = textStyle.copyWith(fontSize: textStyles.fontSize.toDouble() / 2);
}
if (textStyles.formats.contains("italic")) {
textStyle = textStyle.copyWith(fontStyle: FontStyle.italic);
}
if (textStyles.formats.contains("bold")) {
textStyle = textStyle.copyWith(fontWeight: FontWeight.bold);
}
if (textStyles.formats.contains("single-underline")) {
textStyle = textStyle.copyWith(decoration: TextDecoration.underline);
}
if (textStyles.formats.contains("double-underline")) {
textStyle = textStyle.copyWith(decoration: TextDecoration.underline, decorationStyle: TextDecorationStyle.double);
}
if (textStyles.formats.contains("strike")) {
textStyle = textStyle.copyWith(decoration: TextDecoration.lineThrough);
}
if (textStyles.formats.contains("subscript")) {
subScript = true;
}
if (textStyles.formats.contains("superscript")) {
superScript = true;
}
if (textStyles.textColor != null && textStyles.textColor != "auto") {
Color selectedColor = Color(int.parse("FF${textStyles.textColor!}", radix: 16));
textStyle = textStyle.copyWith(color: selectedColor);
} else {
textStyle = textStyle.copyWith(color: Colors.black);
}
if (textStyles.fonts.isNotEmpty) {
textStyle = textStyle.copyWith(fontFamily: textStyles.fonts["ascii"]);
}
}
}
if (subScript || superScript) {
double fontSize = textStyle.fontSize ?? 22;
textStyle = textStyle.copyWith(fontSize: fontSize / 3).copyWith(color: Colors.grey);
if (subScript) {
return RichText(
text: WidgetSpan(
child: Transform.translate(
offset: const Offset(0.0, 1.0),
child: Text(
tempSpanText,
style: textStyle,
),
),
));
} else {
return RichText(
text: WidgetSpan(
child: Transform.translate(
offset: const Offset(0.0, -3.0),
child: Text(
tempSpanText,
style: textStyle,
),
),
));
}
} else {
return RichText(text: TextSpan(text: tempSpanText, style: textStyle));
}
}