saminsohag

codeBuilder argument passed to MdWidget

@@ -259,7 +259,7 @@ @@ -259,7 +259,7 @@
259 isa = PBXProject; 259 isa = PBXProject;
260 attributes = { 260 attributes = {
261 LastSwiftUpdateCheck = 0920; 261 LastSwiftUpdateCheck = 0920;
262 - LastUpgradeCheck = 1430; 262 + LastUpgradeCheck = 1510;
263 ORGANIZATIONNAME = ""; 263 ORGANIZATIONNAME = "";
264 TargetAttributes = { 264 TargetAttributes = {
265 331C80D4294CF70F00263BE5 = { 265 331C80D4294CF70F00263BE5 = {
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <Scheme 2 <Scheme
3 - LastUpgradeVersion = "1430" 3 + LastUpgradeVersion = "1510"
4 version = "1.3"> 4 version = "1.3">
5 <BuildAction 5 <BuildAction
6 parallelizeBuildables = "YES" 6 parallelizeBuildables = "YES"
@@ -215,6 +215,30 @@ packages: @@ -215,6 +215,30 @@ packages:
215 url: "https://pub.dev" 215 url: "https://pub.dev"
216 source: hosted 216 source: hosted
217 version: "0.6.7" 217 version: "0.6.7"
  218 + leak_tracker:
  219 + dependency: transitive
  220 + description:
  221 + name: leak_tracker
  222 + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
  223 + url: "https://pub.dev"
  224 + source: hosted
  225 + version: "10.0.0"
  226 + leak_tracker_flutter_testing:
  227 + dependency: transitive
  228 + description:
  229 + name: leak_tracker_flutter_testing
  230 + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
  231 + url: "https://pub.dev"
  232 + source: hosted
  233 + version: "2.0.1"
  234 + leak_tracker_testing:
  235 + dependency: transitive
  236 + description:
  237 + name: leak_tracker_testing
  238 + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
  239 + url: "https://pub.dev"
  240 + source: hosted
  241 + version: "2.0.1"
218 lints: 242 lints:
219 dependency: transitive 243 dependency: transitive
220 description: 244 description:
@@ -227,26 +251,26 @@ packages: @@ -227,26 +251,26 @@ packages:
227 dependency: transitive 251 dependency: transitive
228 description: 252 description:
229 name: matcher 253 name: matcher
230 - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" 254 + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
231 url: "https://pub.dev" 255 url: "https://pub.dev"
232 source: hosted 256 source: hosted
233 - version: "0.12.16" 257 + version: "0.12.16+1"
234 material_color_utilities: 258 material_color_utilities:
235 dependency: transitive 259 dependency: transitive
236 description: 260 description:
237 name: material_color_utilities 261 name: material_color_utilities
238 - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" 262 + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
239 url: "https://pub.dev" 263 url: "https://pub.dev"
240 source: hosted 264 source: hosted
241 - version: "0.5.0" 265 + version: "0.8.0"
242 meta: 266 meta:
243 dependency: transitive 267 dependency: transitive
244 description: 268 description:
245 name: meta 269 name: meta
246 - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e 270 + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
247 url: "https://pub.dev" 271 url: "https://pub.dev"
248 source: hosted 272 source: hosted
249 - version: "1.10.0" 273 + version: "1.11.0"
250 nested: 274 nested:
251 dependency: transitive 275 dependency: transitive
252 description: 276 description:
@@ -259,10 +283,10 @@ packages: @@ -259,10 +283,10 @@ packages:
259 dependency: transitive 283 dependency: transitive
260 description: 284 description:
261 name: path 285 name: path
262 - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" 286 + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
263 url: "https://pub.dev" 287 url: "https://pub.dev"
264 source: hosted 288 source: hosted
265 - version: "1.8.3" 289 + version: "1.9.0"
266 path_parsing: 290 path_parsing:
267 dependency: transitive 291 dependency: transitive
268 description: 292 description:
@@ -588,6 +612,14 @@ packages: @@ -588,6 +612,14 @@ packages:
588 url: "https://pub.dev" 612 url: "https://pub.dev"
589 source: hosted 613 source: hosted
590 version: "2.1.4" 614 version: "2.1.4"
  615 + vm_service:
  616 + dependency: transitive
  617 + description:
  618 + name: vm_service
  619 + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
  620 + url: "https://pub.dev"
  621 + source: hosted
  622 + version: "13.0.0"
591 web: 623 web:
592 dependency: transitive 624 dependency: transitive
593 description: 625 description:
@@ -41,7 +41,8 @@ abstract class MarkdownComponent { @@ -41,7 +41,8 @@ abstract class MarkdownComponent {
41 final Widget Function(BuildContext context, String tex)? codeBuilder, 41 final Widget Function(BuildContext context, String tex)? codeBuilder,
42 ) { 42 ) {
43 List<InlineSpan> spans = []; 43 List<InlineSpan> spans = [];
44 - List<String> regexes = components.map<String>((e) => e.exp.pattern).toList(); 44 + List<String> regexes =
  45 + components.map<String>((e) => e.exp.pattern).toList();
45 final combinedRegex = RegExp( 46 final combinedRegex = RegExp(
46 regexes.join("|"), 47 regexes.join("|"),
47 multiLine: true, 48 multiLine: true,
@@ -215,12 +216,30 @@ class HTag extends BlockMd { @@ -215,12 +216,30 @@ class HTag extends BlockMd {
215 context, 216 context,
216 "${match?[2]}", 217 "${match?[2]}",
217 [ 218 [
218 - Theme.of(context).textTheme.headlineLarge?.copyWith(color: style?.color),  
219 - Theme.of(context).textTheme.headlineMedium?.copyWith(color: style?.color),  
220 - Theme.of(context).textTheme.headlineSmall?.copyWith(color: style?.color),  
221 - Theme.of(context).textTheme.titleLarge?.copyWith(color: style?.color),  
222 - Theme.of(context).textTheme.titleMedium?.copyWith(color: style?.color),  
223 - Theme.of(context).textTheme.titleSmall?.copyWith(color: style?.color), 219 + Theme.of(context)
  220 + .textTheme
  221 + .headlineLarge
  222 + ?.copyWith(color: style?.color),
  223 + Theme.of(context)
  224 + .textTheme
  225 + .headlineMedium
  226 + ?.copyWith(color: style?.color),
  227 + Theme.of(context)
  228 + .textTheme
  229 + .headlineSmall
  230 + ?.copyWith(color: style?.color),
  231 + Theme.of(context)
  232 + .textTheme
  233 + .titleLarge
  234 + ?.copyWith(color: style?.color),
  235 + Theme.of(context)
  236 + .textTheme
  237 + .titleMedium
  238 + ?.copyWith(color: style?.color),
  239 + Theme.of(context)
  240 + .textTheme
  241 + .titleSmall
  242 + ?.copyWith(color: style?.color),
224 ][match![1]!.length - 1], 243 ][match![1]!.length - 1],
225 textDirection, 244 textDirection,
226 (url, title) {}, 245 (url, title) {},
@@ -321,6 +340,7 @@ class CheckBoxMd extends BlockMd { @@ -321,6 +340,7 @@ class CheckBoxMd extends BlockMd {
321 style: style, 340 style: style,
322 latexWorkaround: latexWorkaround, 341 latexWorkaround: latexWorkaround,
323 latexBuilder: latexBuilder, 342 latexBuilder: latexBuilder,
  343 + codeBuilder: codeBuilder,
324 ), 344 ),
325 ); 345 );
326 } 346 }
@@ -354,6 +374,7 @@ class RadioButtonMd extends BlockMd { @@ -354,6 +374,7 @@ class RadioButtonMd extends BlockMd {
354 style: style, 374 style: style,
355 latexWorkaround: latexWorkaround, 375 latexWorkaround: latexWorkaround,
356 latexBuilder: latexBuilder, 376 latexBuilder: latexBuilder,
  377 + codeBuilder: codeBuilder,
357 ), 378 ),
358 ); 379 );
359 } 380 }
@@ -390,7 +411,15 @@ class IndentMd extends BlockMd { @@ -390,7 +411,15 @@ class IndentMd extends BlockMd {
390 textDirection: textDirection, 411 textDirection: textDirection,
391 child: RichText( 412 child: RichText(
392 text: TextSpan( 413 text: TextSpan(
393 - children: MarkdownComponent.generate(context, "${match?[2]}", style, textDirection, onLinkTab, latexWorkaround, latexBuilder, codeBuilder), 414 + children: MarkdownComponent.generate(
  415 + context,
  416 + "${match?[2]}",
  417 + style,
  418 + textDirection,
  419 + onLinkTab,
  420 + latexWorkaround,
  421 + latexBuilder,
  422 + codeBuilder),
394 )), 423 )),
395 ); 424 );
396 } 425 }
@@ -426,6 +455,7 @@ class UnOrderedList extends BlockMd { @@ -426,6 +455,7 @@ class UnOrderedList extends BlockMd {
426 style: style, 455 style: style,
427 latexWorkaround: latexWorkaround, 456 latexWorkaround: latexWorkaround,
428 latexBuilder: latexBuilder, 457 latexBuilder: latexBuilder,
  458 + codeBuilder: codeBuilder,
429 ), 459 ),
430 ); 460 );
431 } 461 }
@@ -461,6 +491,7 @@ class OrderedList extends BlockMd { @@ -461,6 +491,7 @@ class OrderedList extends BlockMd {
461 style: style, 491 style: style,
462 latexWorkaround: latexWorkaround, 492 latexWorkaround: latexWorkaround,
463 latexBuilder: latexBuilder, 493 latexBuilder: latexBuilder,
  494 + codeBuilder: codeBuilder,
464 ), 495 ),
465 ); 496 );
466 } 497 }
@@ -522,14 +553,16 @@ class BoldMd extends InlineMd { @@ -522,14 +553,16 @@ class BoldMd extends InlineMd {
522 children: MarkdownComponent.generate( 553 children: MarkdownComponent.generate(
523 context, 554 context,
524 "${match?[1]}", 555 "${match?[1]}",
525 - style?.copyWith(fontWeight: FontWeight.bold) ?? const TextStyle(fontWeight: FontWeight.w900), 556 + style?.copyWith(fontWeight: FontWeight.bold) ??
  557 + const TextStyle(fontWeight: FontWeight.w900),
526 textDirection, 558 textDirection,
527 onLinkTab, 559 onLinkTab,
528 latexWorkaround, 560 latexWorkaround,
529 latexBuilder, 561 latexBuilder,
530 codeBuilder, 562 codeBuilder,
531 ), 563 ),
532 - style: style?.copyWith(fontWeight: FontWeight.bold) ?? const TextStyle(fontWeight: FontWeight.bold), 564 + style: style?.copyWith(fontWeight: FontWeight.bold) ??
  565 + const TextStyle(fontWeight: FontWeight.bold),
533 ); 566 );
534 } 567 }
535 } 568 }
@@ -571,7 +604,8 @@ class LatexMathMultyLine extends BlockMd { @@ -571,7 +604,8 @@ class LatexMathMultyLine extends BlockMd {
571 options: MathOptions( 604 options: MathOptions(
572 sizeUnderTextStyle: MathSize.large, 605 sizeUnderTextStyle: MathSize.large,
573 color: style?.color ?? Theme.of(context).colorScheme.onSurface, 606 color: style?.color ?? Theme.of(context).colorScheme.onSurface,
574 - fontSize: style?.fontSize ?? Theme.of(context).textTheme.bodyMedium?.fontSize, 607 + fontSize: style?.fontSize ??
  608 + Theme.of(context).textTheme.bodyMedium?.fontSize,
575 mathFontOptions: FontOptions( 609 mathFontOptions: FontOptions(
576 fontFamily: "Main", 610 fontFamily: "Main",
577 fontWeight: style?.fontWeight ?? FontWeight.normal, 611 fontWeight: style?.fontWeight ?? FontWeight.normal,
@@ -588,7 +622,9 @@ class LatexMathMultyLine extends BlockMd { @@ -588,7 +622,9 @@ class LatexMathMultyLine extends BlockMd {
588 return Text( 622 return Text(
589 workaround(mathText), 623 workaround(mathText),
590 textDirection: textDirection, 624 textDirection: textDirection,
591 - style: style?.copyWith(color: Theme.of(context).colorScheme.error) ?? TextStyle(color: Theme.of(context).colorScheme.error), 625 + style: style?.copyWith(
  626 + color: Theme.of(context).colorScheme.error) ??
  627 + TextStyle(color: Theme.of(context).colorScheme.error),
592 ); 628 );
593 }, 629 },
594 ); 630 );
@@ -638,7 +674,8 @@ class LatexMath extends InlineMd { @@ -638,7 +674,8 @@ class LatexMath extends InlineMd {
638 options: MathOptions( 674 options: MathOptions(
639 sizeUnderTextStyle: MathSize.large, 675 sizeUnderTextStyle: MathSize.large,
640 color: style?.color ?? Theme.of(context).colorScheme.onSurface, 676 color: style?.color ?? Theme.of(context).colorScheme.onSurface,
641 - fontSize: style?.fontSize ?? Theme.of(context).textTheme.bodyMedium?.fontSize, 677 + fontSize: style?.fontSize ??
  678 + Theme.of(context).textTheme.bodyMedium?.fontSize,
642 mathFontOptions: FontOptions( 679 mathFontOptions: FontOptions(
643 fontFamily: "Main", 680 fontFamily: "Main",
644 fontWeight: style?.fontWeight ?? FontWeight.normal, 681 fontWeight: style?.fontWeight ?? FontWeight.normal,
@@ -655,7 +692,9 @@ class LatexMath extends InlineMd { @@ -655,7 +692,9 @@ class LatexMath extends InlineMd {
655 return Text( 692 return Text(
656 workaround(mathText), 693 workaround(mathText),
657 textDirection: textDirection, 694 textDirection: textDirection,
658 - style: style?.copyWith(color: Theme.of(context).colorScheme.error) ?? TextStyle(color: Theme.of(context).colorScheme.error), 695 + style:
  696 + style?.copyWith(color: Theme.of(context).colorScheme.error) ??
  697 + TextStyle(color: Theme.of(context).colorScheme.error),
659 ); 698 );
660 }, 699 },
661 ), 700 ),
@@ -762,7 +801,8 @@ class ImageMd extends InlineMd { @@ -762,7 +801,8 @@ class ImageMd extends InlineMd {
762 double? height; 801 double? height;
763 double? width; 802 double? width;
764 if (match?[1] != null) { 803 if (match?[1] != null) {
765 - var size = RegExp(r"^([0-9]+)?x?([0-9]+)?").firstMatch(match![1].toString().trim()); 804 + var size = RegExp(r"^([0-9]+)?x?([0-9]+)?")
  805 + .firstMatch(match![1].toString().trim());
766 width = double.tryParse(size?[1]?.toString().trim() ?? 'a'); 806 width = double.tryParse(size?[1]?.toString().trim() ?? 'a');
767 height = double.tryParse(size?[2]?.toString().trim() ?? 'a'); 807 height = double.tryParse(size?[2]?.toString().trim() ?? 'a');
768 } 808 }
@@ -775,12 +815,16 @@ class ImageMd extends InlineMd { @@ -775,12 +815,16 @@ class ImageMd extends InlineMd {
775 image: NetworkImage( 815 image: NetworkImage(
776 "${match?[2]}", 816 "${match?[2]}",
777 ), 817 ),
778 - loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) { 818 + loadingBuilder: (BuildContext context, Widget child,
  819 + ImageChunkEvent? loadingProgress) {
779 if (loadingProgress == null) { 820 if (loadingProgress == null) {
780 return child; 821 return child;
781 } 822 }
782 return CustomImageLoading( 823 return CustomImageLoading(
783 - progress: loadingProgress.expectedTotalBytes != null ? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes! : 1, 824 + progress: loadingProgress.expectedTotalBytes != null
  825 + ? loadingProgress.cumulativeBytesLoaded /
  826 + loadingProgress.expectedTotalBytes!
  827 + : 1,
784 ); 828 );
785 }, 829 },
786 fit: BoxFit.fill, 830 fit: BoxFit.fill,
@@ -809,7 +853,11 @@ class TableMd extends BlockMd { @@ -809,7 +853,11 @@ class TableMd extends BlockMd {
809 final List<Map<int, String>> value = text 853 final List<Map<int, String>> value = text
810 .split('\n') 854 .split('\n')
811 .map<Map<int, String>>( 855 .map<Map<int, String>>(
812 - (e) => e.split('|').where((element) => element.isNotEmpty).toList().asMap(), 856 + (e) => e
  857 + .split('|')
  858 + .where((element) => element.isNotEmpty)
  859 + .toList()
  860 + .asMap(),
813 ) 861 )
814 .toList(); 862 .toList();
815 bool heading = RegExp( 863 bool heading = RegExp(
@@ -840,7 +888,9 @@ class TableMd extends BlockMd { @@ -840,7 +888,9 @@ class TableMd extends BlockMd {
840 (entry) => TableRow( 888 (entry) => TableRow(
841 decoration: (heading) 889 decoration: (heading)
842 ? BoxDecoration( 890 ? BoxDecoration(
843 - color: (entry.key == 0) ? Theme.of(context).colorScheme.surfaceVariant : null, 891 + color: (entry.key == 0)
  892 + ? Theme.of(context).colorScheme.surfaceVariant
  893 + : null,
844 ) 894 )
845 : null, 895 : null,
846 children: List.generate( 896 children: List.generate(
@@ -848,13 +898,15 @@ class TableMd extends BlockMd { @@ -848,13 +898,15 @@ class TableMd extends BlockMd {
848 (index) { 898 (index) {
849 var e = entry.value; 899 var e = entry.value;
850 String data = e[index] ?? ""; 900 String data = e[index] ?? "";
851 - if (RegExp(r"^--+$").hasMatch(data.trim()) || data.trim().isEmpty) { 901 + if (RegExp(r"^--+$").hasMatch(data.trim()) ||
  902 + data.trim().isEmpty) {
852 return const SizedBox(); 903 return const SizedBox();
853 } 904 }
854 905
855 return Center( 906 return Center(
856 child: Padding( 907 child: Padding(
857 - padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), 908 + padding: const EdgeInsets.symmetric(
  909 + horizontal: 8, vertical: 4),
858 child: MdWidget( 910 child: MdWidget(
859 (e[index] ?? "").trim(), 911 (e[index] ?? "").trim(),
860 textDirection: textDirection, 912 textDirection: textDirection,
@@ -862,6 +914,7 @@ class TableMd extends BlockMd { @@ -862,6 +914,7 @@ class TableMd extends BlockMd {
862 style: style, 914 style: style,
863 latexWorkaround: latexWorkaround, 915 latexWorkaround: latexWorkaround,
864 latexBuilder: latexBuilder, 916 latexBuilder: latexBuilder,
  917 + codeBuilder: codeBuilder,
865 ), 918 ),
866 ), 919 ),
867 ); 920 );
@@ -902,7 +955,9 @@ class CodeBlockMd extends BlockMd { @@ -902,7 +955,9 @@ class CodeBlockMd extends BlockMd {
902 codes = codes.replaceAll(r"```", "").trim(); 955 codes = codes.replaceAll(r"```", "").trim();
903 return Padding( 956 return Padding(
904 padding: const EdgeInsets.all(16.0), 957 padding: const EdgeInsets.all(16.0),
905 - child: codeBuilder != null ? codeBuilder(context, codes) : CodeField(name: name, codes: codes), 958 + child: codeBuilder != null
  959 + ? codeBuilder(context, codes)
  960 + : CodeField(name: name, codes: codes),
906 ); 961 );
907 } 962 }
908 } 963 }
@@ -931,7 +986,8 @@ class _CodeFieldState extends State<CodeField> { @@ -931,7 +986,8 @@ class _CodeFieldState extends State<CodeField> {
931 Row( 986 Row(
932 children: [ 987 children: [
933 Padding( 988 Padding(
934 - padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8), 989 + padding:
  990 + const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8),
935 child: Text(widget.name), 991 child: Text(widget.name),
936 ), 992 ),
937 const Spacer(), 993 const Spacer(),
@@ -943,7 +999,8 @@ class _CodeFieldState extends State<CodeField> { @@ -943,7 +999,8 @@ class _CodeFieldState extends State<CodeField> {
943 ), 999 ),
944 ), 1000 ),
945 onPressed: () async { 1001 onPressed: () async {
946 - await Clipboard.setData(ClipboardData(text: widget.codes)).then((value) { 1002 + await Clipboard.setData(ClipboardData(text: widget.codes))
  1003 + .then((value) {
947 setState(() { 1004 setState(() {
948 _copied = true; 1005 _copied = true;
949 }); 1006 });