@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22import 'package:flutter_markdown/flutter_markdown.dart' ;
33import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart' ;
44import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart' ;
5+ import 'package:gsy_github_app_flutter/widget/syntax_highlighter.dart' ;
56
67/**
78 * 代码详情
@@ -23,18 +24,21 @@ class GSYMarkdownWidget extends StatelessWidget {
2324 GSYMarkdownWidget ({this .markdownData = "" , this .style = DARK_WHITE });
2425
2526 _getCommonSheet (BuildContext context, Color codeBackground) {
26- MarkdownStyleSheet markdownStyleSheet = MarkdownStyleSheet .fromTheme (Theme .of (context));
27+ MarkdownStyleSheet markdownStyleSheet =
28+ MarkdownStyleSheet .fromTheme (Theme .of (context));
2729 return markdownStyleSheet
2830 .copyWith (
2931 codeblockDecoration: new BoxDecoration (
3032 borderRadius: BorderRadius .all (Radius .circular (4.0 )),
3133 color: codeBackground,
32- border: new Border .all (color: Color (GSYColors .subTextColor), width: 0.3 )))
34+ border: new Border .all (
35+ color: Color (GSYColors .subTextColor), width: 0.3 )))
3336 .copyWith (
3437 blockquoteDecoration: new BoxDecoration (
3538 borderRadius: BorderRadius .all (Radius .circular (4.0 )),
3639 color: Color (GSYColors .subTextColor),
37- border: new Border .all (color: Color (GSYColors .subTextColor), width: 0.3 )),
40+ border: new Border .all (
41+ color: Color (GSYColors .subTextColor), width: 0.3 )),
3842 blockquote: GSYConstant .smallTextWhite);
3943 }
4044
@@ -123,7 +127,9 @@ class GSYMarkdownWidget extends StatelessWidget {
123127 String match = imageMatch.replaceAll ("\) " , "?raw=true)" );
124128 if (! match.contains (".svg" ) && match.contains ("http" )) {
125129 ///增加点击
126- String src = match.replaceAll (new RegExp (r'!\[.*\]\(' ), "" ).replaceAll (")" , "" );
130+ String src = match
131+ .replaceAll (new RegExp (r'!\[.*\]\(' ), "" )
132+ .replaceAll (")" , "" );
127133 String actionMatch = "[$match ]($src )" ;
128134 match = actionMatch;
129135 } else {
@@ -145,7 +151,9 @@ class GSYMarkdownWidget extends StatelessWidget {
145151 for (Match srcMatch in srcTags) {
146152 String srcString = srcMatch.group (0 );
147153 if (srcString != null && srcString.contains ("http" )) {
148- String newSrc = srcString.substring (srcString.indexOf ("http" ), srcString.length - 1 ) + "?raw=true" ;
154+ String newSrc = srcString.substring (
155+ srcString.indexOf ("http" ), srcString.length - 1 ) +
156+ "?raw=true" ;
149157
150158 ///增加点击
151159 match = "[]($newSrc )" ;
@@ -181,9 +189,7 @@ class GSYMarkdownWidget extends StatelessWidget {
181189class GSYHighlighter extends SyntaxHighlighter {
182190 @override
183191 TextSpan format (String source) {
184- return new TextSpan (
185- text: source,
186- style: GSYConstant .smallTextWhite,
187- );
192+ print (source);
193+ return new DartSyntaxHighlighter ().format (source);
188194 }
189195}
0 commit comments