이모티콘 포함된 텍스트 길이 구하기
void emojiTextLength() {
RegExp exp = new RegExp(r'(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])');
String str = "Hello 🌬️🌬️🌬️🌬️🌬️🌬️🌬️ there";
Iterable<Match> matches = exp.allMatches(str);
int emojiLength = 0;
matches.forEach((m) => emojiLength += m.group(0).length);
print(str.length - emojiLength + matches.length);
}
한글인지 아닌지 구분
final regExp = RegExp('[가-힣]+');
if (RegExp('[가-힣]+').hasMatch(line)) {
}
텍스트가 몇 줄인지 확인
1. text 위젯의 Size 파악
- 해당 함수의 결과 값은 Size Type으로 반환
- size.width / size.height를 이용하여 너비, 높이를 알 수 있음
Size _textSize(String text, TextStyle style) {
final TextPainter textPainter = TextPainter(
text: TextSpan(text: text, style: style<),
maxLines: 1,
textDirection: TextDirection.ltr
)..layout(minWidth: 0, maxWidth: double.infinity);
return textPainter.size;
}
2. text 위젯의 String 전체 줄 수
- text를 특정 style로 표현 시, 화면에 표현 되는 전체 줄 수 반환
- 해당 값을 이용해 문자열이 화면에 보여질 줄 수 조정
int textlines(TextStyle style, double textWidth, String text) {
final TextPainter textPainter = TextPainter(
text: TextSpan(text: text, style: style),
textDirection: TextDirection.ltr,
maxLines: 1,
)..layout(minWidth: 0, maxWidth: double.infinity);
List<UI.LineMetrics> countLines = textPainter.computeLineMetrics();
return countLines;
}
종성 체크
bool checkBottomConsonant(String input) {
return (input.runes.last - 0xAC00) % 28!=0;
}