-
RichText() 텍스트 꾸미기프로그래밍 공부 메모/flutter 2022. 7. 6. 17:38
" Hello bold world! " 해당 텍스트 작성 시 TextSpan()으로 문단을 구분 짓고 특정 문단을 꾸며 줄 수 있다
예시 1)
RichText( text: TextSpan( text: 'Hello ', style: DefaultTextStyle.of(context).style, //디폴트 텍스트 스타일 적용으로 모든 요소들에게 적용 children: const <TextSpan>[ TextSpan(text: 'bold', style: TextStyle(fontWeight: FontWeight.bold)), //특정 요소에 style정용시 우선적용 TextSpan(text: ' world!'), ], ), )
예시 2)
RichText( text: TextSpan( children: [ TextSpan(text: 'Hello '), TextSpan(text: 'bold', style: TextStyle(fontWeight: FontWeight.bold)), TextSpan(text: ' world!'), ]) )
[ 위젯 트리 구성 ]
Make text styling more effective with RichText widget
As the name suggests, RichText provides more options to the way a text is displayed on screen.
medium.com
반응형'프로그래밍 공부 메모 > flutter' 카테고리의 다른 글
위젯에서 if문 쓰기 (inline if) (0) 2022.07.07 MediaQuery 디바이스의 정보를 가져오기 (0) 2022.07.06 dynamic / var 차이점 (0) 2022.06.25 GetX (simple state manager with GetBulider 로) 만들기 1 (0) 2022.06.21 앱이 시작할때 세팅하기 (0) 2022.06.18