@@ -29,11 +29,15 @@ class GSYMarkdownWidget extends StatelessWidget {
2929 final String baseUrl;
3030
3131 final int style;
32+ final bool shrinkWrap;
33+ final bool scroll;
3234
3335 const GSYMarkdownWidget (
3436 {super .key,
3537 this .markdownData = "" ,
3638 required this .baseUrl,
39+ this .shrinkWrap = false ,
40+ this .scroll = true ,
3741 this .style = DARK_WHITE });
3842
3943 _getCommonSheet (BuildContext context, Color codeBackground) {
@@ -243,28 +247,30 @@ class GSYMarkdownWidget extends StatelessWidget {
243247 color: _getBackgroundColor (context),
244248 padding: const EdgeInsets .all (5.0 ),
245249 child: Markdown (
246- styleSheet: _getStyle (context),
247- syntaxHighlighter: GSYHighlighter (),
248- data: _processMarkdownImages (markdownData! , baseUrl),
249- imageBuilder: (Uri ? uri, String ? title, String ? alt) {
250- if (uri == null || uri.toString ().isEmpty) return const SizedBox ();
251- final StringList parts = uri.toString ().split ('#' );
252- double ? width;
253- double ? height;
254- if (parts.length == 2 ) {
255- final StringList dimensions = parts.last.split ('x' );
256- if (dimensions.length == 2 ) {
257- var [ws, hs] = dimensions;
258- width = double .parse (ws);
259- height = double .parse (hs);
260- }
250+ styleSheet: _getStyle (context),
251+ syntaxHighlighter: GSYHighlighter (),
252+ shrinkWrap: shrinkWrap,
253+ physics: scroll ? null : const NeverScrollableScrollPhysics (),
254+ data: _processMarkdownImages (markdownData! , baseUrl),
255+ imageBuilder: (Uri ? uri, String ? title, String ? alt) {
256+ if (uri == null || uri.toString ().isEmpty) return const SizedBox ();
257+ final StringList parts = uri.toString ().split ('#' );
258+ double ? width;
259+ double ? height;
260+ if (parts.length == 2 ) {
261+ final StringList dimensions = parts.last.split ('x' );
262+ if (dimensions.length == 2 ) {
263+ var [ws, hs] = dimensions;
264+ width = double .parse (ws);
265+ height = double .parse (hs);
261266 }
262- return kDefaultImageBuilder (uri, "" , width, height);
263- },
264- onTapLink: (String text, String ? href, String title) {
265- CommonUtils .gsyLaunchUrl (context, href);
266- },
267- ),
267+ }
268+ return kDefaultImageBuilder (uri, "" , width, height);
269+ },
270+ onTapLink: (String text, String ? href, String title) {
271+ CommonUtils .gsyLaunchUrl (context, href);
272+ },
273+ ),
268274 );
269275 }
270276}
0 commit comments