Markdown viewer 를 만들기 위해서는 라이브러리를 받아야한다.
https://pub.dev/packages/flutter_markdown
flutter_markdown | Flutter Package
A Markdown renderer for Flutter. Create rich text output, including text styles, tables, links, and more, from plain text data formatted with simple Markdown tags.
pub.dev
flutter pub add flutter_markdown
적용법은 매우 간단하다.
Markdown(data: 'markdown String here')
커스텀 디자인은 어떻게 할 수 있을까?
styleSheet: MarkdownStyleSheet()
이렇게 styleSheet 인자에 MarkdownStyleSheet를 넘겨주면 된다.
styleSheet: MarkdownStyleSheet(
h1: const TextStyle(
fontSize: 24, color: Colors.red, fontWeight: FontWeight.w700),
h2: const TextStyle(color: Colors.pink, fontSize: 30),
),
전체 코드는 아래와 같다.
적용 되지 않는 문법들도 존재하니, 꼭 공식문서를 확인해보기를 바란다.
적용 가능한 objects는 뭐가 있을까
위 사진을 참고하여 다양한 스타일을 적용해 보면 될 것 같다!
'develop > Flutter' 카테고리의 다른 글
[Flutter] VSCode flutter 프로젝트 생성하기 (0) | 2022.10.29 |
---|---|
[Flutter] dart class 선언하기 & 생성자 (0) | 2022.10.27 |
[Flutter] Navigator.of(context) .push / .then 화면 전환 보낸 화면에서 데이터 받기 (0) | 2022.10.19 |
[Flutter] dart List선언하기 하기 (dart 기초 2-1) (0) | 2022.10.17 |
[Flutter] dart 출력 하기, 변수/상수 선언 하기 (dart 기초 1) (0) | 2022.10.13 |