saminsohag

Scrolling feature of block type latex added

1 import 'dart:developer'; 1 import 'dart:developer';
2 2
3 import 'package:flutter/material.dart'; 3 import 'package:flutter/material.dart';
  4 +import 'package:flutter_math_fork/flutter_math.dart';
4 import 'package:gpt_markdown/gpt_markdown.dart'; 5 import 'package:gpt_markdown/gpt_markdown.dart';
5 6
6 void main() { 7 void main() {
@@ -134,8 +135,7 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex @@ -134,8 +135,7 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
134 width: 1, 135 width: 1,
135 color: Theme.of(context).colorScheme.outline), 136 color: Theme.of(context).colorScheme.outline),
136 ), 137 ),
137 - child:  
138 - LayoutBuilder(builder: (context, constraints) { 138 + child: LayoutBuilder(builder: (context, constraints) {
139 return Theme( 139 return Theme(
140 data: Theme.of(context).copyWith( 140 data: Theme.of(context).copyWith(
141 textTheme: const TextTheme( 141 textTheme: const TextTheme(
@@ -167,15 +167,24 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex @@ -167,15 +167,24 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
167 // Regular text font size here. 167 // Regular text font size here.
168 fontSize: 15, 168 fontSize: 15,
169 ), 169 ),
170 - latexWorkaround: (tex) =>  
171 - tex.replaceAllMapped(RegExp(r"align\*"),  
172 - (match) => "aligned"), 170 + latexWorkaround: (tex) => tex.replaceAllMapped(
  171 + RegExp(r"align\*"), (match) => "aligned"),
  172 + latexBuilder: (contex, tex) {
  173 + return SingleChildScrollView(
  174 + scrollDirection: Axis.horizontal,
  175 + child: Math.tex(
  176 + tex,
  177 + textStyle: const TextStyle(fontSize: 17),
  178 + ),
  179 + );
  180 + },
173 ), 181 ),
174 // child: const Text("Hello"), 182 // child: const Text("Hello"),
175 ); 183 );
176 }), 184 }),
177 ); 185 );
178 - }), 186 + },
  187 + ),
179 ], 188 ],
180 ), 189 ),
181 ), 190 ),
@@ -143,7 +143,7 @@ packages: @@ -143,7 +143,7 @@ packages:
143 source: hosted 143 source: hosted
144 version: "2.0.3" 144 version: "2.0.3"
145 flutter_math_fork: 145 flutter_math_fork:
146 - dependency: transitive 146 + dependency: "direct main"
147 description: 147 description:
148 name: flutter_math_fork 148 name: flutter_math_fork
149 sha256: "94bee4642892a94939af0748c6a7de0ff8318feee588379dcdfea7dc5cba06c8" 149 sha256: "94bee4642892a94939af0748c6a7de0ff8318feee588379dcdfea7dc5cba06c8"
@@ -20,6 +20,7 @@ dependencies: @@ -20,6 +20,7 @@ dependencies:
20 path_provider: ^2.0.14 20 path_provider: ^2.0.14
21 permission_handler: ^10.2.0 21 permission_handler: ^10.2.0
22 file_picker: ^5.2.10 22 file_picker: ^5.2.10
  23 + flutter_math_fork: ^0.7.2
23 24
24 dev_dependencies: 25 dev_dependencies:
25 flutter_test: 26 flutter_test:
@@ -16,6 +16,7 @@ class TexMarkdown extends StatelessWidget { @@ -16,6 +16,7 @@ class TexMarkdown extends StatelessWidget {
16 this.textAlign, 16 this.textAlign,
17 this.textScaler, 17 this.textScaler,
18 this.onLinkTab, 18 this.onLinkTab,
  19 + this.latexBuilder,
19 }); 20 });
20 final TextDirection textDirection; 21 final TextDirection textDirection;
21 final String data; 22 final String data;
@@ -24,6 +25,7 @@ class TexMarkdown extends StatelessWidget { @@ -24,6 +25,7 @@ class TexMarkdown extends StatelessWidget {
24 final TextScaler? textScaler; 25 final TextScaler? textScaler;
25 final void Function(String url, String title)? onLinkTab; 26 final void Function(String url, String title)? onLinkTab;
26 final String Function(String tex)? latexWorkaround; 27 final String Function(String tex)? latexWorkaround;
  28 + final Widget Function(BuildContext context, String tex)? latexBuilder;
27 final bool followLinkColor; 29 final bool followLinkColor;
28 30
29 @override 31 @override
@@ -38,6 +40,7 @@ class TexMarkdown extends StatelessWidget { @@ -38,6 +40,7 @@ class TexMarkdown extends StatelessWidget {
38 textScaler: textScaler, 40 textScaler: textScaler,
39 followLinkColor: followLinkColor, 41 followLinkColor: followLinkColor,
40 latexWorkaround: latexWorkaround, 42 latexWorkaround: latexWorkaround,
  43 + latexBuilder: latexBuilder,
41 )); 44 ));
42 } 45 }
43 } 46 }
@@ -32,6 +32,7 @@ abstract class MarkdownComponent { @@ -32,6 +32,7 @@ abstract class MarkdownComponent {
32 TextDirection textDirection, 32 TextDirection textDirection,
33 final void Function(String url, String title)? onLinkTab, 33 final void Function(String url, String title)? onLinkTab,
34 final String Function(String tex)? latexWorkaround, 34 final String Function(String tex)? latexWorkaround,
  35 + final Widget Function(BuildContext context, String tex)? latexBuilder,
35 ) { 36 ) {
36 List<InlineSpan> spans = []; 37 List<InlineSpan> spans = [];
37 List<String> regexes = 38 List<String> regexes =
@@ -57,6 +58,7 @@ abstract class MarkdownComponent { @@ -57,6 +58,7 @@ abstract class MarkdownComponent {
57 textDirection, 58 textDirection,
58 onLinkTab, 59 onLinkTab,
59 latexWorkaround, 60 latexWorkaround,
  61 + latexBuilder,
60 )); 62 ));
61 } else { 63 } else {
62 if (each is BlockMd) { 64 if (each is BlockMd) {
@@ -76,6 +78,7 @@ abstract class MarkdownComponent { @@ -76,6 +78,7 @@ abstract class MarkdownComponent {
76 textDirection, 78 textDirection,
77 onLinkTab, 79 onLinkTab,
78 latexWorkaround, 80 latexWorkaround,
  81 + latexBuilder,
79 ), 82 ),
80 TextSpan( 83 TextSpan(
81 text: "\n ", 84 text: "\n ",
@@ -114,6 +117,7 @@ abstract class MarkdownComponent { @@ -114,6 +117,7 @@ abstract class MarkdownComponent {
114 TextDirection textDirection, 117 TextDirection textDirection,
115 final void Function(String url, String title)? onLinkTab, 118 final void Function(String url, String title)? onLinkTab,
116 final String Function(String tex)? latexWorkaround, 119 final String Function(String tex)? latexWorkaround,
  120 + final Widget Function(BuildContext context, String tex)? latexBuilder,
117 ); 121 );
118 122
119 RegExp get exp; 123 RegExp get exp;
@@ -133,6 +137,7 @@ abstract class InlineMd extends MarkdownComponent { @@ -133,6 +137,7 @@ abstract class InlineMd extends MarkdownComponent {
133 TextDirection textDirection, 137 TextDirection textDirection,
134 final void Function(String url, String title)? onLinkTab, 138 final void Function(String url, String title)? onLinkTab,
135 final String Function(String tex)? latexWorkaround, 139 final String Function(String tex)? latexWorkaround,
  140 + final Widget Function(BuildContext context, String tex)? latexBuilder,
136 ); 141 );
137 } 142 }
138 143
@@ -148,6 +153,7 @@ abstract class BlockMd extends MarkdownComponent { @@ -148,6 +153,7 @@ abstract class BlockMd extends MarkdownComponent {
148 TextDirection textDirection, 153 TextDirection textDirection,
149 final void Function(String url, String title)? onLinkTab, 154 final void Function(String url, String title)? onLinkTab,
150 final String Function(String tex)? latexWorkaround, 155 final String Function(String tex)? latexWorkaround,
  156 + final Widget Function(BuildContext context, String tex)? latexBuilder,
151 ) { 157 ) {
152 return WidgetSpan( 158 return WidgetSpan(
153 child: build( 159 child: build(
@@ -157,6 +163,7 @@ abstract class BlockMd extends MarkdownComponent { @@ -157,6 +163,7 @@ abstract class BlockMd extends MarkdownComponent {
157 textDirection, 163 textDirection,
158 onLinkTab, 164 onLinkTab,
159 latexWorkaround, 165 latexWorkaround,
  166 + latexBuilder,
160 ), 167 ),
161 alignment: PlaceholderAlignment.middle, 168 alignment: PlaceholderAlignment.middle,
162 ); 169 );
@@ -169,6 +176,7 @@ abstract class BlockMd extends MarkdownComponent { @@ -169,6 +176,7 @@ abstract class BlockMd extends MarkdownComponent {
169 TextDirection textDirection, 176 TextDirection textDirection,
170 final void Function(String url, String title)? onLinkTab, 177 final void Function(String url, String title)? onLinkTab,
171 final String Function(String tex)? latexWorkaround, 178 final String Function(String tex)? latexWorkaround,
  179 + final Widget Function(BuildContext context, String tex)? latexBuilder,
172 ); 180 );
173 } 181 }
174 182
@@ -184,6 +192,7 @@ class HTag extends BlockMd { @@ -184,6 +192,7 @@ class HTag extends BlockMd {
184 TextDirection textDirection, 192 TextDirection textDirection,
185 final void Function(String url, String title)? onLinkTab, 193 final void Function(String url, String title)? onLinkTab,
186 final String Function(String tex)? latexWorkaround, 194 final String Function(String tex)? latexWorkaround,
  195 + final Widget Function(BuildContext context, String tex)? latexBuilder,
187 ) { 196 ) {
188 var match = exp.firstMatch(text.trim()); 197 var match = exp.firstMatch(text.trim());
189 return Text.rich( 198 return Text.rich(
@@ -221,6 +230,7 @@ class HTag extends BlockMd { @@ -221,6 +230,7 @@ class HTag extends BlockMd {
221 textDirection, 230 textDirection,
222 (url, title) {}, 231 (url, title) {},
223 latexWorkaround, 232 latexWorkaround,
  233 + latexBuilder,
224 )), 234 )),
225 if (match[1]!.length == 1) ...[ 235 if (match[1]!.length == 1) ...[
226 const TextSpan( 236 const TextSpan(
@@ -259,6 +269,7 @@ class HrLine extends BlockMd { @@ -259,6 +269,7 @@ class HrLine extends BlockMd {
259 TextDirection textDirection, 269 TextDirection textDirection,
260 final void Function(String url, String title)? onLinkTab, 270 final void Function(String url, String title)? onLinkTab,
261 final String Function(String tex)? latexWorkaround, 271 final String Function(String tex)? latexWorkaround,
  272 + final Widget Function(BuildContext context, String tex)? latexBuilder,
262 ) { 273 ) {
263 return CustomDivider( 274 return CustomDivider(
264 height: 2, 275 height: 2,
@@ -281,6 +292,7 @@ class CheckBoxMd extends BlockMd { @@ -281,6 +292,7 @@ class CheckBoxMd extends BlockMd {
281 TextDirection textDirection, 292 TextDirection textDirection,
282 final void Function(String url, String title)? onLinkTab, 293 final void Function(String url, String title)? onLinkTab,
283 final String Function(String tex)? latexWorkaround, 294 final String Function(String tex)? latexWorkaround,
  295 + final Widget Function(BuildContext context, String tex)? latexBuilder,
284 ) { 296 ) {
285 var match = exp.firstMatch(text.trim()); 297 var match = exp.firstMatch(text.trim());
286 return CustomCb( 298 return CustomCb(
@@ -292,6 +304,7 @@ class CheckBoxMd extends BlockMd { @@ -292,6 +304,7 @@ class CheckBoxMd extends BlockMd {
292 textDirection: textDirection, 304 textDirection: textDirection,
293 style: style, 305 style: style,
294 latexWorkaround: latexWorkaround, 306 latexWorkaround: latexWorkaround,
  307 + latexBuilder: latexBuilder,
295 ), 308 ),
296 ); 309 );
297 } 310 }
@@ -311,6 +324,7 @@ class RadioButtonMd extends BlockMd { @@ -311,6 +324,7 @@ class RadioButtonMd extends BlockMd {
311 TextDirection textDirection, 324 TextDirection textDirection,
312 final void Function(String url, String title)? onLinkTab, 325 final void Function(String url, String title)? onLinkTab,
313 final String Function(String tex)? latexWorkaround, 326 final String Function(String tex)? latexWorkaround,
  327 + final Widget Function(BuildContext context, String tex)? latexBuilder,
314 ) { 328 ) {
315 var match = exp.firstMatch(text.trim()); 329 var match = exp.firstMatch(text.trim());
316 return CustomRb( 330 return CustomRb(
@@ -322,6 +336,7 @@ class RadioButtonMd extends BlockMd { @@ -322,6 +336,7 @@ class RadioButtonMd extends BlockMd {
322 textDirection: textDirection, 336 textDirection: textDirection,
323 style: style, 337 style: style,
324 latexWorkaround: latexWorkaround, 338 latexWorkaround: latexWorkaround,
  339 + latexBuilder: latexBuilder,
325 ), 340 ),
326 ); 341 );
327 } 342 }
@@ -341,6 +356,7 @@ class IndentMd extends BlockMd { @@ -341,6 +356,7 @@ class IndentMd extends BlockMd {
341 TextDirection textDirection, 356 TextDirection textDirection,
342 final void Function(String url, String title)? onLinkTab, 357 final void Function(String url, String title)? onLinkTab,
343 final String Function(String tex)? latexWorkaround, 358 final String Function(String tex)? latexWorkaround,
  359 + final Widget Function(BuildContext context, String tex)? latexBuilder,
344 ) { 360 ) {
345 [ 361 [
346 r"\\\[(.*?)\\\]", 362 r"\\\[(.*?)\\\]",
@@ -356,14 +372,8 @@ class IndentMd extends BlockMd { @@ -356,14 +372,8 @@ class IndentMd extends BlockMd {
356 textDirection: textDirection, 372 textDirection: textDirection,
357 child: RichText( 373 child: RichText(
358 text: TextSpan( 374 text: TextSpan(
359 - children: MarkdownComponent.generate(  
360 - context,  
361 - "${match?[2]}",  
362 - style,  
363 - textDirection,  
364 - onLinkTab,  
365 - latexWorkaround,  
366 - ), 375 + children: MarkdownComponent.generate(context, "${match?[2]}", style,
  376 + textDirection, onLinkTab, latexWorkaround, latexBuilder),
367 )), 377 )),
368 ); 378 );
369 } 379 }
@@ -383,6 +393,7 @@ class UnOrderedList extends BlockMd { @@ -383,6 +393,7 @@ class UnOrderedList extends BlockMd {
383 TextDirection textDirection, 393 TextDirection textDirection,
384 final void Function(String url, String title)? onLinkTab, 394 final void Function(String url, String title)? onLinkTab,
385 final String Function(String tex)? latexWorkaround, 395 final String Function(String tex)? latexWorkaround,
  396 + final Widget Function(BuildContext context, String tex)? latexBuilder,
386 ) { 397 ) {
387 var match = exp.firstMatch(text); 398 var match = exp.firstMatch(text);
388 return UnorderedListView( 399 return UnorderedListView(
@@ -396,6 +407,7 @@ class UnOrderedList extends BlockMd { @@ -396,6 +407,7 @@ class UnOrderedList extends BlockMd {
396 textDirection: textDirection, 407 textDirection: textDirection,
397 style: style, 408 style: style,
398 latexWorkaround: latexWorkaround, 409 latexWorkaround: latexWorkaround,
  410 + latexBuilder: latexBuilder,
399 ), 411 ),
400 ); 412 );
401 } 413 }
@@ -416,6 +428,7 @@ class OrderedList extends BlockMd { @@ -416,6 +428,7 @@ class OrderedList extends BlockMd {
416 TextDirection textDirection, 428 TextDirection textDirection,
417 final void Function(String url, String title)? onLinkTab, 429 final void Function(String url, String title)? onLinkTab,
418 final String Function(String tex)? latexWorkaround, 430 final String Function(String tex)? latexWorkaround,
  431 + final Widget Function(BuildContext context, String tex)? latexBuilder,
419 ) { 432 ) {
420 var match = exp.firstMatch(text.trim()); 433 var match = exp.firstMatch(text.trim());
421 return OrderedListView( 434 return OrderedListView(
@@ -428,6 +441,7 @@ class OrderedList extends BlockMd { @@ -428,6 +441,7 @@ class OrderedList extends BlockMd {
428 textDirection: textDirection, 441 textDirection: textDirection,
429 style: style, 442 style: style,
430 latexWorkaround: latexWorkaround, 443 latexWorkaround: latexWorkaround,
  444 + latexBuilder: latexBuilder,
431 ), 445 ),
432 ); 446 );
433 } 447 }
@@ -446,6 +460,7 @@ class BoldMd extends InlineMd { @@ -446,6 +460,7 @@ class BoldMd extends InlineMd {
446 TextDirection textDirection, 460 TextDirection textDirection,
447 final void Function(String url, String title)? onLinkTab, 461 final void Function(String url, String title)? onLinkTab,
448 final String Function(String tex)? latexWorkaround, 462 final String Function(String tex)? latexWorkaround,
  463 + final Widget Function(BuildContext context, String tex)? latexBuilder,
449 ) { 464 ) {
450 var match = exp.firstMatch(text.trim()); 465 var match = exp.firstMatch(text.trim());
451 return TextSpan( 466 return TextSpan(
@@ -457,6 +472,7 @@ class BoldMd extends InlineMd { @@ -457,6 +472,7 @@ class BoldMd extends InlineMd {
457 textDirection, 472 textDirection,
458 onLinkTab, 473 onLinkTab,
459 latexWorkaround, 474 latexWorkaround,
  475 + latexBuilder,
460 ), 476 ),
461 style: style?.copyWith(fontWeight: FontWeight.bold) ?? 477 style: style?.copyWith(fontWeight: FontWeight.bold) ??
462 const TextStyle(fontWeight: FontWeight.bold), 478 const TextStyle(fontWeight: FontWeight.bold),
@@ -479,16 +495,16 @@ class LatexMathMultyLine extends InlineMd { @@ -479,16 +495,16 @@ class LatexMathMultyLine extends InlineMd {
479 TextDirection textDirection, 495 TextDirection textDirection,
480 final void Function(String url, String title)? onLinkTab, 496 final void Function(String url, String title)? onLinkTab,
481 final String Function(String tex)? latexWorkaround, 497 final String Function(String tex)? latexWorkaround,
  498 + final Widget Function(BuildContext context, String tex)? latexBuilder,
482 ) { 499 ) {
483 var p0 = exp.firstMatch(text.trim()); 500 var p0 = exp.firstMatch(text.trim());
484 p0?.group(0); 501 p0?.group(0);
485 String mathText = p0?[1] ?? p0?[2] ?? ""; 502 String mathText = p0?[1] ?? p0?[2] ?? "";
486 var workaround = latexWorkaround ?? (String tex) => tex; 503 var workaround = latexWorkaround ?? (String tex) => tex;
487 - return WidgetSpan(  
488 - alignment: PlaceholderAlignment.baseline,  
489 - baseline: TextBaseline.alphabetic,  
490 - child: Math.tex(  
491 - workaround(mathText), 504 +
  505 + var builder = latexBuilder ??
  506 + (BuildContext context, String tex) => Math.tex(
  507 + workaround(tex),
492 textStyle: style?.copyWith( 508 textStyle: style?.copyWith(
493 fontFamily: "SansSerif", 509 fontFamily: "SansSerif",
494 ), 510 ),
@@ -518,12 +534,17 @@ class LatexMathMultyLine extends InlineMd { @@ -518,12 +534,17 @@ class LatexMathMultyLine extends InlineMd {
518 return Text( 534 return Text(
519 workaround(mathText), 535 workaround(mathText),
520 textDirection: textDirection, 536 textDirection: textDirection,
521 - style:  
522 - style?.copyWith(color: Theme.of(context).colorScheme.error) ?? 537 + style: style?.copyWith(
  538 + color: Theme.of(context).colorScheme.error) ??
523 TextStyle(color: Theme.of(context).colorScheme.error), 539 TextStyle(color: Theme.of(context).colorScheme.error),
524 ); 540 );
525 }, 541 },
526 - ), 542 + );
  543 +
  544 + return WidgetSpan(
  545 + alignment: PlaceholderAlignment.baseline,
  546 + baseline: TextBaseline.alphabetic,
  547 + child: builder(context, mathText),
527 ); 548 );
528 } 549 }
529 } 550 }
@@ -547,6 +568,7 @@ class LatexMath extends InlineMd { @@ -547,6 +568,7 @@ class LatexMath extends InlineMd {
547 TextDirection textDirection, 568 TextDirection textDirection,
548 final void Function(String url, String title)? onLinkTab, 569 final void Function(String url, String title)? onLinkTab,
549 final String Function(String tex)? latexWorkaround, 570 final String Function(String tex)? latexWorkaround,
  571 + final Widget Function(BuildContext context, String tex)? latexBuilder,
550 ) { 572 ) {
551 var p0 = exp.firstMatch(text.trim()); 573 var p0 = exp.firstMatch(text.trim());
552 p0?.group(0); 574 p0?.group(0);
@@ -609,6 +631,7 @@ class ItalicMd extends InlineMd { @@ -609,6 +631,7 @@ class ItalicMd extends InlineMd {
609 TextDirection textDirection, 631 TextDirection textDirection,
610 final void Function(String url, String title)? onLinkTab, 632 final void Function(String url, String title)? onLinkTab,
611 final String Function(String tex)? latexWorkaround, 633 final String Function(String tex)? latexWorkaround,
  634 + final Widget Function(BuildContext context, String tex)? latexBuilder,
612 ) { 635 ) {
613 var match = exp.firstMatch(text.trim()); 636 var match = exp.firstMatch(text.trim());
614 return TextSpan( 637 return TextSpan(
@@ -619,6 +642,7 @@ class ItalicMd extends InlineMd { @@ -619,6 +642,7 @@ class ItalicMd extends InlineMd {
619 textDirection, 642 textDirection,
620 onLinkTab, 643 onLinkTab,
621 latexWorkaround, 644 latexWorkaround,
  645 + latexBuilder,
622 ), 646 ),
623 style: (style ?? const TextStyle()).copyWith(fontStyle: FontStyle.italic), 647 style: (style ?? const TextStyle()).copyWith(fontStyle: FontStyle.italic),
624 ); 648 );
@@ -638,6 +662,7 @@ class ATagMd extends InlineMd { @@ -638,6 +662,7 @@ class ATagMd extends InlineMd {
638 TextDirection textDirection, 662 TextDirection textDirection,
639 final void Function(String url, String title)? onLinkTab, 663 final void Function(String url, String title)? onLinkTab,
640 final String Function(String tex)? latexWorkaround, 664 final String Function(String tex)? latexWorkaround,
  665 + final Widget Function(BuildContext context, String tex)? latexBuilder,
641 ) { 666 ) {
642 var match = exp.firstMatch(text.trim()); 667 var match = exp.firstMatch(text.trim());
643 if (match?[1] == null && match?[2] == null) { 668 if (match?[1] == null && match?[2] == null) {
@@ -682,6 +707,7 @@ class ImageMd extends InlineMd { @@ -682,6 +707,7 @@ class ImageMd extends InlineMd {
682 TextDirection textDirection, 707 TextDirection textDirection,
683 final void Function(String url, String title)? onLinkTab, 708 final void Function(String url, String title)? onLinkTab,
684 final String Function(String tex)? latexWorkaround, 709 final String Function(String tex)? latexWorkaround,
  710 + final Widget Function(BuildContext context, String tex)? latexBuilder,
685 ) { 711 ) {
686 var match = exp.firstMatch(text.trim()); 712 var match = exp.firstMatch(text.trim());
687 double? height; 713 double? height;
@@ -733,6 +759,7 @@ class TableMd extends BlockMd { @@ -733,6 +759,7 @@ class TableMd extends BlockMd {
733 TextDirection textDirection, 759 TextDirection textDirection,
734 void Function(String url, String title)? onLinkTab, 760 void Function(String url, String title)? onLinkTab,
735 final String Function(String tex)? latexWorkaround, 761 final String Function(String tex)? latexWorkaround,
  762 + final Widget Function(BuildContext context, String tex)? latexBuilder,
736 ) { 763 ) {
737 final List<Map<int, String>> value = text 764 final List<Map<int, String>> value = text
738 .split('\n') 765 .split('\n')
@@ -13,6 +13,7 @@ class MdWidget extends StatelessWidget { @@ -13,6 +13,7 @@ class MdWidget extends StatelessWidget {
13 this.textAlign, 13 this.textAlign,
14 this.textScaler, 14 this.textScaler,
15 this.latexWorkaround, 15 this.latexWorkaround,
  16 + this.latexBuilder,
16 this.followLinkColor = false}); 17 this.followLinkColor = false});
17 final String exp; 18 final String exp;
18 final TextDirection textDirection; 19 final TextDirection textDirection;
@@ -21,6 +22,7 @@ class MdWidget extends StatelessWidget { @@ -21,6 +22,7 @@ class MdWidget extends StatelessWidget {
21 final TextScaler? textScaler; 22 final TextScaler? textScaler;
22 final void Function(String url, String title)? onLinkTab; 23 final void Function(String url, String title)? onLinkTab;
23 final String Function(String tex)? latexWorkaround; 24 final String Function(String tex)? latexWorkaround;
  25 + final Widget Function(BuildContext context, String tex)? latexBuilder;
24 final bool followLinkColor; 26 final bool followLinkColor;
25 27
26 @override 28 @override
@@ -94,6 +96,7 @@ class MdWidget extends StatelessWidget { @@ -94,6 +96,7 @@ class MdWidget extends StatelessWidget {
94 onLinkTab: onLinkTab, 96 onLinkTab: onLinkTab,
95 style: style, 97 style: style,
96 latexWorkaround: latexWorkaround, 98 latexWorkaround: latexWorkaround,
  99 + latexBuilder: latexBuilder,
97 ), 100 ),
98 ); 101 );
99 }, 102 },
@@ -128,6 +131,7 @@ class MdWidget extends StatelessWidget { @@ -128,6 +131,7 @@ class MdWidget extends StatelessWidget {
128 textDirection, 131 textDirection,
129 onLinkTab, 132 onLinkTab,
130 latexWorkaround, 133 latexWorkaround,
  134 + latexBuilder,
131 ), 135 ),
132 ); 136 );
133 } 137 }