diff --git a/packages/flutter_markdown/test/link_test.dart b/packages/flutter_markdown/test/link_test.dart index 1092a6c44e..9a50477822 100644 --- a/packages/flutter_markdown/test/link_test.dart +++ b/packages/flutter_markdown/test/link_test.dart @@ -15,8 +15,8 @@ void defineTests() { testWidgets( 'should work with nested elements', (WidgetTester tester) async { - List linkTapResults = []; - const String data = '[Link `with nested code` Text](href)'; + final linkTapResults = []; + const data = '[Link `with nested code` Text](href)'; await tester.pumpWidget( boilerplate( Markdown( @@ -28,14 +28,16 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; - final List gestureRecognizerTypes = []; + final gestureRecognizerTypes = []; span.visitChildren((InlineSpan inlineSpan) { if (inlineSpan is TextSpan) { - TapGestureRecognizer recognizer = inlineSpan.recognizer as TapGestureRecognizer; - gestureRecognizerTypes.add(recognizer.runtimeType); - recognizer.onTap!(); + final recognizer = inlineSpan.recognizer as TapGestureRecognizer?; + gestureRecognizerTypes.add(recognizer?.runtimeType ?? Null); + if (recognizer != null) { + recognizer.onTap!(); + } } return true; }); @@ -56,9 +58,8 @@ void defineTests() { testWidgets( 'should work next to other links', (WidgetTester tester) async { - List linkTapResults = []; - const String data = - '[First Link](firstHref) and [Second Link](secondHref)'; + final linkTapResults = []; + const data = '[First Link](firstHref) and [Second Link](secondHref)'; await tester.pumpWidget( boilerplate( Markdown( @@ -69,16 +70,18 @@ void defineTests() { ), ); - final RichText textWidget = + final textWidget = tester.widgetList(find.byType(RichText)).first as RichText; final TextSpan span = textWidget.text as TextSpan; - final List gestureRecognizerTypes = []; + final gestureRecognizerTypes = []; span.visitChildren((InlineSpan inlineSpan) { if (inlineSpan is TextSpan) { - TapGestureRecognizer? recognizer = inlineSpan.recognizer as TapGestureRecognizer?; - gestureRecognizerTypes.add(recognizer.runtimeType); - recognizer?.onTap!(); + final recognizer = inlineSpan.recognizer as TapGestureRecognizer?; + gestureRecognizerTypes.add(recognizer?.runtimeType ?? Null); + if (recognizer != null) { + recognizer.onTap!(); + } } return true; }); @@ -99,7 +102,7 @@ void defineTests() { // Example 493 from GFM. 'simple inline link', (WidgetTester tester) async { - const String data = '[link](/uri "title")'; + const data = '[link](/uri "title")'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -119,7 +122,7 @@ void defineTests() { testWidgets( 'empty inline link', (WidgetTester tester) async { - const String data = '[](/uri "title")'; + const data = '[](/uri "title")'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -140,7 +143,7 @@ void defineTests() { // Example 494 from GFM. 'simple inline link - title omitted', (WidgetTester tester) async { - const String data = '[link](/uri)'; + const data = '[link](/uri)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -161,7 +164,7 @@ void defineTests() { // Example 495 from GFM. 'simple inline link - both destination and title omitted', (WidgetTester tester) async { - const String data = '[link]()'; + const data = '[link]()'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -182,7 +185,7 @@ void defineTests() { // Example 496 from GFM. 'simple inline link - both < > enclosed destination and title omitted', (WidgetTester tester) async { - const String data = '[link](<>)'; + const data = '[link](<>)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -203,7 +206,7 @@ void defineTests() { // Example 497 from GFM. 'link destination with space and not < > enclosed', (WidgetTester tester) async { - const String data = '[link](/my url)'; + const data = '[link](/my url)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -225,7 +228,7 @@ void defineTests() { // Example 498 from GFM. 'link destination with space and < > enclosed', (WidgetTester tester) async { - const String data = '[link]()'; + const data = '[link]()'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -249,7 +252,7 @@ void defineTests() { // Example 499 from GFM. 'link destination cannot contain line breaks - not < > enclosed', (WidgetTester tester) async { - const String data = '[link](foo\nbar)'; + const data = '[link](foo\nbar)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -271,7 +274,7 @@ void defineTests() { // Example 500 from GFM. 'link destination cannot contain line breaks - < > enclosed', (WidgetTester tester) async { - const String data = '[link]()'; + const data = '[link]()'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -293,7 +296,7 @@ void defineTests() { // Example 501 from GFM. 'link destination containing ")" and < > enclosed', (WidgetTester tester) async { - const String data = '[link]()'; + const data = '[link]()'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -339,8 +342,7 @@ void defineTests() { // Example 503 from GFM. 'opening pointy brackets are not properly matched', (WidgetTester tester) async { - const String data = - '[link](\n[link](bar)'; + const data = '[link](\n[link](bar)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -362,7 +364,7 @@ void defineTests() { // Example 504 from GFM. 'parentheses inside link destination may be escaped', (WidgetTester tester) async { - const String data = '[link](\(foo\))'; + const data = '[link](\(foo\))'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -383,7 +385,7 @@ void defineTests() { // Example 505 from GFM. 'multiple balanced parentheses are allowed without escaping', (WidgetTester tester) async { - const String data = '[link](foo(and(bar)))'; + const data = '[link](foo(and(bar)))'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -404,7 +406,7 @@ void defineTests() { // Example 506 from GFM. 'escaped unbalanced parentheses', (WidgetTester tester) async { - const String data = '[link](foo\(and\(bar\))'; + const data = '[link](foo\(and\(bar\))'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -428,7 +430,7 @@ void defineTests() { // Example 507 from GFM. 'pointy brackets enclosed unbalanced parentheses', (WidgetTester tester) async { - const String data = '[link]()'; + const data = '[link]()'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -449,7 +451,7 @@ void defineTests() { // Example 508 from GFM. 'parentheses and other symbols can be escaped', (WidgetTester tester) async { - const String data = '[link](foo\)\:)'; + const data = '[link](foo\)\:)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -473,7 +475,7 @@ void defineTests() { // Example 509 case 1 from GFM. 'link destinations with just fragment identifier', (WidgetTester tester) async { - const String data = '[link](#fragment)'; + const data = '[link](#fragment)'; MarkdownLink? linkTapResults; await tester.pumpWidget( @@ -495,7 +497,7 @@ void defineTests() { // Example 509 case 2 from GFM. 'link destinations with URL and fragment identifier', (WidgetTester tester) async { - const String data = '[link](http://example.com#fragment)'; + const data = '[link](http://example.com#fragment)'; MarkdownLink? linkTapResults; await tester.pumpWidget( @@ -518,7 +520,7 @@ void defineTests() { // Example 509 case 3 from GFM. 'link destinations with URL, fragment identifier, and query', (WidgetTester tester) async { - const String data = '[link](http://example.com?foo=3#fragment)'; + const data = '[link](http://example.com?foo=3#fragment)'; MarkdownLink? linkTapResults; await tester.pumpWidget( @@ -541,7 +543,7 @@ void defineTests() { // Example 510 from GFM. 'link destinations with backslash before non-escapable character', (WidgetTester tester) async { - const String data = '[link](foo\bar)'; + const data = '[link](foo\bar)'; MarkdownLink? linkTapResults; await tester.pumpWidget( @@ -563,7 +565,7 @@ void defineTests() { // Example 511 from GFM. 'URL escaping should be left alone inside link destination', (WidgetTester tester) async { - const String data = '[link](foo%20bä)'; + const data = '[link](foo%20bä)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -584,7 +586,7 @@ void defineTests() { // Example 512 from GFM. 'omitting link destination uses title for destination', (WidgetTester tester) async { - const String data = '[link]("title")'; + const data = '[link]("title")'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -605,7 +607,7 @@ void defineTests() { // Example 513a from GFM. 'link title in double quotes', (WidgetTester tester) async { - const String data = '[link](/url "title")'; + const data = '[link](/url "title")'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -626,7 +628,7 @@ void defineTests() { // Example 513b from GFM. 'link title in single quotes', (WidgetTester tester) async { - const String data = '[link](/url \'title\')'; + const data = '[link](/url \'title\')'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -647,7 +649,7 @@ void defineTests() { // Example 513c from GFM. 'link title in parentheses', (WidgetTester tester) async { - const String data = '[link](/url (title))'; + const data = '[link](/url (title))'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -668,7 +670,7 @@ void defineTests() { // Example 514 from GFM. 'backslash escapes, entity, and numeric character references are allowed in title', (WidgetTester tester) async { - const String data = '[link](/url "title \""")'; + const data = '[link](/url "title \""")'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -693,7 +695,7 @@ void defineTests() { // Example 515 from GFM. 'link title must be separated with whitespace and not Unicode whitespace', (WidgetTester tester) async { - const String data = '[link](/url\u{C2A0}"title")'; + const data = '[link](/url\u{C2A0}"title")'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -715,7 +717,7 @@ void defineTests() { // Example 516 from GFM. 'nested balanced quotes are not allowed without escaping', (WidgetTester tester) async { - const String data = '[link](/url "title "and" title")'; + const data = '[link](/url "title "and" title")'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -737,7 +739,7 @@ void defineTests() { // Example 517 from GFM. 'nested balanced quotes using different quote type', (WidgetTester tester) async { - const String data = '[link](/url \'title "and" title\')'; + const data = '[link](/url \'title "and" title\')'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -759,7 +761,7 @@ void defineTests() { // Example 518 from GFM. 'whitespace is allowed around the destination and title', (WidgetTester tester) async { - const String data = '[link]( /url "title")'; + const data = '[link]( /url "title")'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -780,7 +782,7 @@ void defineTests() { // Example 519 from GFM. 'whitespace is not allowed between link text and following parentheses', (WidgetTester tester) async { - const String data = '[link] (/url)'; + const data = '[link] (/url)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -802,7 +804,7 @@ void defineTests() { // Example 520 from GFM. 'link text may contain balanced brackets', (WidgetTester tester) async { - const String data = '[link [foo [bar]]](/uri)'; + const data = '[link [foo [bar]]](/uri)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -823,7 +825,7 @@ void defineTests() { // Example 521 from GFM. 'link text may not contain unbalanced brackets', (WidgetTester tester) async { - const String data = '[link] bar](/uri)'; + const data = '[link] bar](/uri)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -845,7 +847,7 @@ void defineTests() { // Example 522 from GFM. 'link text may not contain unbalanced brackets - unintended link text', (WidgetTester tester) async { - const String data = '[link [bar](/uri)'; + const data = '[link [bar](/uri)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -872,7 +874,7 @@ void defineTests() { // Example 523 from GFM. 'link text with escaped open square bracket', (WidgetTester tester) async { - const String data = r'[link \[bar](/uri)'; + const data = r'[link \[bar](/uri)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -893,7 +895,7 @@ void defineTests() { // Example 524 from GFM. 'link text with inline emphasis and code', (WidgetTester tester) async { - const String data = '[link *foo **bar** `#`*](/uri)'; + const data = '[link *foo **bar** `#`*](/uri)'; List linkTapResults = []; await tester.pumpWidget( boilerplate( @@ -906,9 +908,10 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 5); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); expectTextSpanStyle( span.children![1] as TextSpan, FontStyle.italic, FontWeight.normal); expectTextSpanStyle( @@ -917,10 +920,11 @@ void defineTests() { span.children![3] as TextSpan, FontStyle.italic, FontWeight.normal); expect((span.children![4] as TextSpan).style!.fontFamily, 'monospace'); - final List gestureRecognizerTypes = []; + final gestureRecognizerTypes = []; span.visitChildren((InlineSpan inlineSpan) { if (inlineSpan is TextSpan) { - TapGestureRecognizer recognizer = inlineSpan.recognizer as TapGestureRecognizer; + TapGestureRecognizer recognizer = + inlineSpan.recognizer as TapGestureRecognizer; gestureRecognizerTypes.add(recognizer.runtimeType); recognizer.onTap!(); } @@ -942,7 +946,7 @@ void defineTests() { // Example 525 from GFM. 'inline image link text', (WidgetTester tester) async { - const String data = '[![moon](moon.jpg)](/uri)'; + const data = '[![moon](moon.jpg)](/uri)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -956,7 +960,7 @@ void defineTests() { final gestureFinder = find.byType(GestureDetector); expect(gestureFinder, findsOneWidget); - final GestureDetector gestureWidget = + final gestureWidget = gestureFinder.evaluate().first.widget as GestureDetector; expect(gestureWidget.child, isA()); expect(gestureWidget.onTap, isNotNull); @@ -970,7 +974,7 @@ void defineTests() { // Example 526 from GFM. 'links cannot be nested - outter link ignored', (WidgetTester tester) async { - const String data = '[foo [bar](/uri)](/uri)'; + const data = '[foo [bar](/uri)](/uri)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -983,7 +987,7 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 3); expect(span.children![0], isA()); expect(span.children![0].toPlainText(), '[foo '); @@ -1000,7 +1004,7 @@ void defineTests() { // Example 527 from GFM. 'links cannot be nested - outter link ignored with emphasis', (WidgetTester tester) async { - const String data = '[foo *[bar [baz](/uri)](/uri)*](/uri)'; + const data = '[foo *[bar [baz](/uri)](/uri)*](/uri)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1013,12 +1017,13 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 5); expect(span.children, everyElement(isA())); expect(span.children![0].toPlainText(), '[foo '); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); expect(span.children![1].toPlainText(), '[bar '); expectTextSpanStyle( @@ -1033,7 +1038,8 @@ void defineTests() { span.children![3] as TextSpan, FontStyle.italic, FontWeight.normal); expect(span.children![4].toPlainText(), '](/uri)'); - expectTextSpanStyle(span.children![4] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![4] as TextSpan, null, FontWeight.normal); expectLinkTextSpan(span.children![2] as TextSpan, 'baz'); expectLinkTap(linkTapResults, MarkdownLink('baz', '/uri')); @@ -1044,7 +1050,7 @@ void defineTests() { // Example 528 from GFM. 'links cannot be nested in image linksinline image link text', (WidgetTester tester) async { - const String data = '![[[foo](uri1)](uri2)](uri3)'; + const data = '![[[foo](uri1)](uri2)](uri3)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1072,7 +1078,7 @@ void defineTests() { // Example 529 from GFM. 'link text grouping has precedence over emphasis grouping example 1', (WidgetTester tester) async { - const String data = '*[foo*](/uri)'; + const data = '*[foo*](/uri)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1085,11 +1091,12 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expect(span.children![0], isA()); expect(span.children![0].toPlainText(), '*'); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); expectLinkTextSpan(span.children![1] as TextSpan, 'foo*'); expectLinkTap(linkTapResults, MarkdownLink('foo*', '/uri')); @@ -1103,7 +1110,7 @@ void defineTests() { // Example 530 from GFM. 'link text grouping has precedence over emphasis grouping example 2', (WidgetTester tester) async { - const String data = '[foo *bar](baz*)'; + const data = '[foo *bar](baz*)'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1124,7 +1131,7 @@ void defineTests() { // Example 531 from GFM. 'brackets that aren\'t part of links do not take precedence', (WidgetTester tester) async { - const String data = '*foo [bar* baz]'; + const data = '*foo [bar* baz]'; await tester.pumpWidget( boilerplate( MarkdownBody(data: data), @@ -1132,7 +1139,7 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expect(span.children, everyElement(isA())); @@ -1141,7 +1148,8 @@ void defineTests() { span.children![0] as TextSpan, FontStyle.italic, FontWeight.normal); expect(span.children![1].toPlainText(), ' baz]'); - expectTextSpanStyle(span.children![1] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![1] as TextSpan, null, FontWeight.normal); }, ); @@ -1149,7 +1157,7 @@ void defineTests() { // Example 532 from GFM. 'HTML tag takes precedence over link grouping', (WidgetTester tester) async { - const String data = '[foo '; + const data = '[foo '; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1171,7 +1179,7 @@ void defineTests() { // Example 533 from GFM. 'code span takes precedence over link grouping', (WidgetTester tester) async { - const String data = '[foo`](/uri)`'; + const data = '[foo`](/uri)`'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1187,15 +1195,17 @@ void defineTests() { expect(gestureFinder, findsNothing); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expect(span.children, everyElement(isA())); expect(span.children![0], isA()); expect(span.children![0].toPlainText(), '[foo'); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); expect((span.children![1] as TextSpan).style!.fontFamily, 'monospace'); expect(linkTapResults, isNull); }, @@ -1205,7 +1215,7 @@ void defineTests() { // Example 534 from GFM. 'autolinks take precedence over link grouping', (WidgetTester tester) async { - const String data = '[foo'; + const data = '[foo'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1218,12 +1228,13 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expect(span.children, everyElement(isA())); expect(span.children![0].toPlainText(), '[foo'); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); expectLinkTextSpan( span.children![1] as TextSpan, 'http://example.com/?search=](uri)'); @@ -1239,7 +1250,7 @@ void defineTests() { // Example 535 from GFM. 'simple reference link', (WidgetTester tester) async { - const String data = '[foo][bar]\n\n[bar]: /url "title"'; + const data = '[foo][bar]\n\n[bar]: /url "title"'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1260,7 +1271,7 @@ void defineTests() { // Example 536 from GFM. 'reference link with balanced brackets in link text', (WidgetTester tester) async { - const String data = '[link [foo [bar]]][ref]\n\n[ref]: /uri'; + const data = '[link [foo [bar]]][ref]\n\n[ref]: /uri'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1281,7 +1292,7 @@ void defineTests() { // Example 537 from GFM. 'reference link with unbalanced but escaped bracket in link text', (WidgetTester tester) async { - const String data = '[link \[bar][ref]\n\n[ref]: /uri'; + const data = '[link \[bar][ref]\n\n[ref]: /uri'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1305,7 +1316,7 @@ void defineTests() { // Example 538 from GFM. 'reference link with inline emphasis and code span in link text', (WidgetTester tester) async { - const String data = '[link *foo **bar** `#`*][ref]\n\n[ref]: /uri'; + const data = '[link *foo **bar** `#`*][ref]\n\n[ref]: /uri'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1318,12 +1329,13 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 5); expect(span.children, everyElement(isA())); expect(span.children![0].toPlainText(), 'link '); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); expect(span.children![1].toPlainText(), 'foo '); expectTextSpanStyle( @@ -1338,14 +1350,15 @@ void defineTests() { span.children![3] as TextSpan, FontStyle.italic, FontWeight.normal); expect(span.children![4].toPlainText(), '#'); - expectTextSpanStyle(span.children![4] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![4] as TextSpan, null, FontWeight.normal); expect((span.children![4] as TextSpan).style!.fontFamily, 'monospace'); span.children!.forEach((element) { - TextSpan textSpan = element as TextSpan; + final textSpan = element as TextSpan; expect(textSpan.recognizer, isNotNull); expect(textSpan.recognizer, isA()); - final TapGestureRecognizer tapRecognizer = textSpan.recognizer as TapGestureRecognizer; + final tapRecognizer = textSpan.recognizer as TapGestureRecognizer; expect(tapRecognizer.onTap, isNotNull); tapRecognizer.onTap!(); @@ -1361,7 +1374,7 @@ void defineTests() { // Example 539 from GFM. 'referenence link with inline image link text', (WidgetTester tester) async { - const String data = '[![moon](moon.jpg)][ref]\n\n[ref]: /uri'; + const data = '[![moon](moon.jpg)][ref]\n\n[ref]: /uri'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1375,7 +1388,7 @@ void defineTests() { final gestureFinder = find.byType(GestureDetector); expect(gestureFinder, findsOneWidget); - final GestureDetector gestureWidget = + final gestureWidget = gestureFinder.evaluate().first.widget as GestureDetector; expect(gestureWidget.child, isA()); expect(gestureWidget.onTap, isNotNull); @@ -1389,7 +1402,7 @@ void defineTests() { // Example 540 from GFM. 'reference links cannot have nested links', (WidgetTester tester) async { - const String data = '[foo [bar](/uri)][ref]\n\n[ref]: /uri'; + const data = '[foo [bar](/uri)][ref]\n\n[ref]: /uri'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1402,7 +1415,7 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 4); expect(span.children![0], isA()); @@ -1423,7 +1436,7 @@ void defineTests() { // Example 541 from GFM. 'reference links cannot have nested reference links', (WidgetTester tester) async { - const String data = '[foo *bar [baz][ref]*][ref]\n\n[ref]: /uri'; + const data = '[foo *bar [baz][ref]*][ref]\n\n[ref]: /uri'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1436,12 +1449,13 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 5); expect(span.children![0], isA()); expect(span.children![0].toPlainText(), '[foo '); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); expect(span.children![1], isA()); expect(span.children![1].toPlainText(), 'bar '); @@ -1455,10 +1469,12 @@ void defineTests() { expect(span.children![3], isA()); expect(span.children![3].toPlainText(), ']'); - expectTextSpanStyle(span.children![3] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![3] as TextSpan, null, FontWeight.normal); expectLinkTextSpan(span.children![4] as TextSpan, 'ref'); - expectTextSpanStyle(span.children![4] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![4] as TextSpan, null, FontWeight.normal); expectLinkTap(linkTapResults, MarkdownLink('ref', '/uri')); }, ); @@ -1467,7 +1483,7 @@ void defineTests() { // Example 542 from GFM. 'reference link text grouping has precedence over emphasis grouping example 1', (WidgetTester tester) async { - const String data = '*[foo*][ref]\n\n[ref]: /uri'; + const data = '*[foo*][ref]\n\n[ref]: /uri'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1480,11 +1496,12 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expect(span.children![0], isA()); expect(span.children![0].toPlainText(), '*'); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); expectLinkTextSpan(span.children![1] as TextSpan, 'foo*'); expectLinkTap(linkTapResults, MarkdownLink('foo*', '/uri')); @@ -1498,7 +1515,7 @@ void defineTests() { // Example 543 from GFM. 'reference link text grouping has precedence over emphasis grouping example 2', (WidgetTester tester) async { - const String data = '[foo *bar][ref]*\n\n[ref]: /uri'; + const data = '[foo *bar][ref]*\n\n[ref]: /uri'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1511,16 +1528,18 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expectLinkTextSpan(span.children![0] as TextSpan, 'foo *bar'); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); expectLinkTap(linkTapResults, MarkdownLink('foo *bar', '/uri')); expect(span.children![1], isA()); expect(span.children![1].toPlainText(), '*'); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); }, ); @@ -1528,7 +1547,7 @@ void defineTests() { // Example 544 from GFM. 'HTML tag takes precedence over reference link grouping', (WidgetTester tester) async { - const String data = '[foo \n\n[ref]: /uri'; + const data = '[foo \n\n[ref]: /uri'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1550,7 +1569,7 @@ void defineTests() { // Example 545 from GFM. 'code span takes precedence over reference link grouping', (WidgetTester tester) async { - const String data = '[foo`][ref]`\n\n[ref]: /uri'; + const data = '[foo`][ref]`\n\n[ref]: /uri'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1566,13 +1585,14 @@ void defineTests() { expect(gestureFinder, findsNothing); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expect(span.children, everyElement(isA())); expect(span.children![0], isA()); expect(span.children![0].toPlainText(), '[foo'); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); expect(span.children![1].toPlainText(), '][ref]'); expect((span.children![1] as TextSpan).style!.fontFamily, 'monospace'); @@ -1584,8 +1604,7 @@ void defineTests() { // Example 534 from GFM. 'autolinks take precedence over reference link grouping', (WidgetTester tester) async { - const String data = - '[foo\n\n[ref]: /uri'; + const data = '[foo\n\n[ref]: /uri'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1598,12 +1617,13 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expect(span.children, everyElement(isA())); expect(span.children![0].toPlainText(), '[foo'); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); expectLinkTextSpan( span.children![1] as TextSpan, 'http://example.com/?search=][ref]'); @@ -1618,7 +1638,7 @@ void defineTests() { // Example 547 from GFM. 'reference link matching is case-insensitive', (WidgetTester tester) async { - const String data = '[foo][BaR]\n\n[bar]: /url "title"'; + const data = '[foo][BaR]\n\n[bar]: /url "title"'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1639,7 +1659,7 @@ void defineTests() { // Example 548 from GFM. 'reference link support Unicode case fold - GFM', (WidgetTester tester) async { - const String data = '[ẞ]\n\n[SS]: /url'; + const data = '[ẞ]\n\n[SS]: /url'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1665,8 +1685,7 @@ void defineTests() { // to the test suite since each example produces different cases to test. 'reference link support Unicode case fold - CommonMark', (WidgetTester tester) async { - const String data = - '[Толпой][Толпой] is a Russian word.\n\n[ТОЛПОЙ]: /url'; + const data = '[Толпой][Толпой] is a Russian word.\n\n[ТОЛПОЙ]: /url'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1679,7 +1698,7 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expectLinkTextSpan(span.children![0] as TextSpan, 'Толпой'); @@ -1687,7 +1706,8 @@ void defineTests() { expect(span.children![1], isA()); expect(span.children![1].toPlainText(), ' is a Russian word.'); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); }, ); @@ -1695,7 +1715,7 @@ void defineTests() { // Example 549 from GFM. 'reference link with internal whitespace', (WidgetTester tester) async { - const String data = '[Foo\n bar]: /url\n\n[Baz][Foo bar]'; + const data = '[Foo\n bar]: /url\n\n[Baz][Foo bar]'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1716,7 +1736,7 @@ void defineTests() { // Example 550 from GFM. 'reference link no whitespace between link text and link label', (WidgetTester tester) async { - const String data = '[foo] [bar]\n\n[bar]: /url "title"'; + const data = '[foo] [bar]\n\n[bar]: /url "title"'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1729,12 +1749,13 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expect(span.children![0], isA()); expect(span.children![0].toPlainText(), '[foo] '); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); expectLinkTextSpan(span.children![1] as TextSpan, 'bar'); expectLinkTap(linkTapResults, MarkdownLink('bar', '/url', 'title')); @@ -1745,7 +1766,7 @@ void defineTests() { // Example 551 from GFM. 'reference link no line break between link text and link label', (WidgetTester tester) async { - const String data = '[foo]\n[bar]\n\n[bar]: /url "title"'; + const data = '[foo]\n[bar]\n\n[bar]: /url "title"'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1758,12 +1779,13 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expect(span.children![0], isA()); expect(span.children![0].toPlainText(), '[foo] '); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); expectLinkTextSpan(span.children![1] as TextSpan, 'bar'); expectLinkTap(linkTapResults, MarkdownLink('bar', '/url', 'title')); @@ -1774,7 +1796,7 @@ void defineTests() { // Example 552 from GFM. 'multiple matching reference link definitions use first definition', (WidgetTester tester) async { - const String data = '[foo]: /url1\n\n[foo]: /url2\n\n[bar][foo]'; + const data = '[foo]: /url1\n\n[foo]: /url2\n\n[bar][foo]'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1795,7 +1817,7 @@ void defineTests() { // Example 553 from GFM. 'reference link matching is performed on normalized strings', (WidgetTester tester) async { - const String data = '[bar][foo\!]\n\n[foo!]: /url'; + const data = '[bar][foo\!]\n\n[foo!]: /url'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1820,7 +1842,7 @@ void defineTests() { // Example 554 from GFM. 'reference link labels cannot contain brackets - case 1', (WidgetTester tester) async { - const String data = '[foo][ref[]\n\n[ref[]: /uri'; + const data = '[foo][ref[]\n\n[ref[]: /uri'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1832,17 +1854,19 @@ void defineTests() { ), ); - final List textWidgets = + final textWidgets = tester.widgetList(find.byType(RichText)).toList().cast(); expect(textWidgets.length, 2); expect(textWidgets[0].text, isA()); expect(textWidgets[0].text.toPlainText(), '[foo][ref[]'); - expectTextSpanStyle(textWidgets[0].text as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + textWidgets[0].text as TextSpan, null, FontWeight.normal); expect(textWidgets[1].text, isA()); expect(textWidgets[1].text.toPlainText(), '[ref[]: /uri'); - expectTextSpanStyle(textWidgets[1].text as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + textWidgets[1].text as TextSpan, null, FontWeight.normal); expect(linkTapResults, isNull); }, @@ -1855,7 +1879,7 @@ void defineTests() { // Example 555 from GFM. 'reference link labels cannot contain brackets - case 2', (WidgetTester tester) async { - const String data = '[foo][ref[bar]]\n\n[ref[bar]]: /uri'; + const data = '[foo][ref[bar]]\n\n[ref[bar]]: /uri'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1867,19 +1891,21 @@ void defineTests() { ), ); - final List textWidgets = + final textWidgets = tester.widgetList(find.byType(RichText)).toList().cast(); expect(textWidgets.length, 2); expect(textWidgets[0].text, isNotNull); expect(textWidgets[0].text, isA()); expect(textWidgets[0].text.toPlainText(), '[foo][ref[bar]]'); - expectTextSpanStyle(textWidgets[0].text as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + textWidgets[0].text as TextSpan, null, FontWeight.normal); expect(textWidgets[1].text, isNotNull); expect(textWidgets[1].text, isA()); expect(textWidgets[1].text.toPlainText(), '[ref[bar]]: /uri'); - expectTextSpanStyle(textWidgets[1].text as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + textWidgets[1].text as TextSpan, null, FontWeight.normal); expect(linkTapResults, isNull); }, @@ -1889,7 +1915,7 @@ void defineTests() { // Example 556 from GFM. 'reference link labels cannot contain brackets - case 3', (WidgetTester tester) async { - const String data = '[[[foo]]]\n\n[[[foo]]]: /url'; + const data = '[[[foo]]]\n\n[[[foo]]]: /url'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1901,19 +1927,21 @@ void defineTests() { ), ); - final List textWidgets = + final textWidgets = tester.widgetList(find.byType(RichText)).toList().cast(); expect(textWidgets.length, 2); expect(textWidgets[0].text, isNotNull); expect(textWidgets[0].text, isA()); expect(textWidgets[0].text.toPlainText(), '[[[foo]]]'); - expectTextSpanStyle(textWidgets[0].text as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + textWidgets[0].text as TextSpan, null, FontWeight.normal); expect(textWidgets[1].text, isNotNull); expect(textWidgets[1].text, isA()); expect(textWidgets[1].text.toPlainText(), '[[[foo]]]: /url'); - expectTextSpanStyle(textWidgets[1].text as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + textWidgets[1].text as TextSpan, null, FontWeight.normal); expect(linkTapResults, isNull); }, @@ -1923,7 +1951,7 @@ void defineTests() { // Example 557 from GFM. 'reference link labels can have escaped brackets', (WidgetTester tester) async { - const String data = '[foo][ref\[]\n\n[ref\[]: /uri'; + const data = '[foo][ref\[]\n\n[ref\[]: /uri'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1944,7 +1972,7 @@ void defineTests() { // Example 558 from GFM. 'reference link labels can have escaped characters', (WidgetTester tester) async { - const String data = '[bar\\]: /uri\n\n[bar\\]'; + const data = '[bar\\]: /uri\n\n[bar\\]'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1968,7 +1996,7 @@ void defineTests() { // Example 559 from GFM. 'reference link labels must contain at least on non-whitespace character - case 1', (WidgetTester tester) async { - const String data = '[]\n\n[]: /uri'; + const data = '[]\n\n[]: /uri'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1980,19 +2008,21 @@ void defineTests() { ), ); - final List textWidgets = + final textWidgets = tester.widgetList(find.byType(RichText)).toList().cast(); expect(textWidgets.length, 2); expect(textWidgets[0].text, isNotNull); expect(textWidgets[0].text, isA()); expect(textWidgets[0].text.toPlainText(), '[]'); - expectTextSpanStyle(textWidgets[0].text as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + textWidgets[0].text as TextSpan, null, FontWeight.normal); expect(textWidgets[1].text, isNotNull); expect(textWidgets[1].text, isA()); expect(textWidgets[1].text.toPlainText(), '[]: /uri'); - expectTextSpanStyle(textWidgets[1].text as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + textWidgets[1].text as TextSpan, null, FontWeight.normal); expect(linkTapResults, isNull); }, @@ -2002,7 +2032,7 @@ void defineTests() { // Example 560 from GFM. 'reference link labels must contain at least on non-whitespace character - case 2', (WidgetTester tester) async { - const String data = '[\n ]\n\n[\n ]: /uri'; + const data = '[\n ]\n\n[\n ]: /uri'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2014,19 +2044,21 @@ void defineTests() { ), ); - final List textWidgets = + final textWidgets = tester.widgetList(find.byType(RichText)).toList().cast(); expect(textWidgets.length, 2); expect(textWidgets[0].text, isNotNull); expect(textWidgets[0].text, isA()); expect(textWidgets[0].text.toPlainText(), '[ ]'); - expectTextSpanStyle(textWidgets[0].text as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + textWidgets[0].text as TextSpan, null, FontWeight.normal); expect(textWidgets[1].text, isNotNull); expect(textWidgets[1].text, isA()); expect(textWidgets[1].text.toPlainText(), '[ ]: /uri'); - expectTextSpanStyle(textWidgets[1].text as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + textWidgets[1].text as TextSpan, null, FontWeight.normal); expect(linkTapResults, isNull); }, @@ -2036,7 +2068,7 @@ void defineTests() { // Example 561 from GFM. 'collapsed reference link', (WidgetTester tester) async { - const String data = '[foo][]\n\n[foo]: /url "title"'; + const data = '[foo][]\n\n[foo]: /url "title"'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2057,7 +2089,7 @@ void defineTests() { // Example 562 from GFM. 'collapsed reference link with inline emphasis in link text', (WidgetTester tester) async { - const String data = '[*foo* bar][]\n\n[*foo* bar]: /url "title"'; + const data = '[*foo* bar][]\n\n[*foo* bar]: /url "title"'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2070,7 +2102,7 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expect(span.children, everyElement(isA())); @@ -2079,13 +2111,14 @@ void defineTests() { span.children![0] as TextSpan, FontStyle.italic, FontWeight.normal); expect(span.children![1].toPlainText(), ' bar'); - expectTextSpanStyle(span.children![1] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![1] as TextSpan, null, FontWeight.normal); span.children!.forEach((element) { - TextSpan textSpan = element as TextSpan; + final textSpan = element as TextSpan; expect(textSpan.recognizer, isNotNull); expect(textSpan.recognizer, isA()); - final TapGestureRecognizer tapRecognizer = textSpan.recognizer as TapGestureRecognizer; + final tapRecognizer = textSpan.recognizer as TapGestureRecognizer; expect(tapRecognizer.onTap, isNotNull); tapRecognizer.onTap!(); @@ -2102,7 +2135,7 @@ void defineTests() { // Example 563 from GFM. 'collapsed reference links are case-insensitive', (WidgetTester tester) async { - const String data = '[Foo][]\n\n[foo]: /url "title"'; + const data = '[Foo][]\n\n[foo]: /url "title"'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2123,7 +2156,7 @@ void defineTests() { // Example 564 from GFM. 'collapsed reference link no whitespace between link text and link label', (WidgetTester tester) async { - const String data = '[foo] \n\n[]\n\n[foo]: /url "title"'; + const data = '[foo] \n\n[]\n\n[foo]: /url "title"'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2135,7 +2168,7 @@ void defineTests() { ), ); - final List textWidgets = + final textWidgets = tester.widgetList(find.byType(RichText)).toList().cast(); expect(textWidgets.length, 2); @@ -2151,7 +2184,8 @@ void defineTests() { expect(textWidgets[1].text, isNotNull); expect(textWidgets[1].text, isA()); expect(textWidgets[1].text.toPlainText(), '[]'); - expectTextSpanStyle(textWidgets[1].text as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + textWidgets[1].text as TextSpan, null, FontWeight.normal); }, ); @@ -2159,7 +2193,7 @@ void defineTests() { // Example 565 from GFM. 'shortcut reference link', (WidgetTester tester) async { - const String data = '[foo]\n\n[foo]: /url "title"'; + const data = '[foo]\n\n[foo]: /url "title"'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2180,7 +2214,7 @@ void defineTests() { // Example 566 from GFM. 'shortcut reference link with inline emphasis in link text', (WidgetTester tester) async { - const String data = '[*foo* bar]\n\n[*foo* bar]: /url "title"'; + const data = '[*foo* bar]\n\n[*foo* bar]: /url "title"'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2193,7 +2227,7 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expect(span.children, everyElement(isA())); @@ -2202,13 +2236,14 @@ void defineTests() { span.children![0] as TextSpan, FontStyle.italic, FontWeight.normal); expect(span.children![1].toPlainText(), ' bar'); - expectTextSpanStyle(span.children![1] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![1] as TextSpan, null, FontWeight.normal); span.children!.forEach((element) { - TextSpan textSpan = element as TextSpan; + final textSpan = element as TextSpan; expect(textSpan.recognizer, isNotNull); expect(textSpan.recognizer, isA()); - final TapGestureRecognizer tapRecognizer = textSpan.recognizer as TapGestureRecognizer; + final tapRecognizer = textSpan.recognizer as TapGestureRecognizer; expect(tapRecognizer.onTap, isNotNull); tapRecognizer.onTap!(); @@ -2225,7 +2260,7 @@ void defineTests() { // Example 567 from GFM. 'shortcut reference link with inline emphasis nested in link text', (WidgetTester tester) async { - const String data = '[*foo* bar]\n\n[*foo* bar]: /url "title"'; + const data = '[*foo* bar]\n\n[*foo* bar]: /url "title"'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2238,7 +2273,7 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expect(span.children, everyElement(isA())); @@ -2247,13 +2282,14 @@ void defineTests() { span.children![0] as TextSpan, FontStyle.italic, FontWeight.normal); expect(span.children![1].toPlainText(), ' bar'); - expectTextSpanStyle(span.children![1] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![1] as TextSpan, null, FontWeight.normal); span.children!.forEach((element) { - TextSpan textSpan = element as TextSpan; + final textSpan = element as TextSpan; expect(textSpan.recognizer, isNotNull); expect(textSpan.recognizer, isA()); - final TapGestureRecognizer tapRecognizer = textSpan.recognizer as TapGestureRecognizer; + final tapRecognizer = textSpan.recognizer as TapGestureRecognizer; expect(tapRecognizer.onTap, isNotNull); tapRecognizer.onTap!(); @@ -2270,7 +2306,7 @@ void defineTests() { // Example 568 from GFM. 'shortcut reference link with unbalanced open square brackets', (WidgetTester tester) async { - const String data = '[[bar [foo]\n\n[foo]: /url'; + const data = '[[bar [foo]\n\n[foo]: /url'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2283,12 +2319,13 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expect(span.children![0], isA()); expect(span.children![0].toPlainText(), '[[bar '); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); expectLinkTextSpan(span.children![1] as TextSpan, 'foo'); expectLinkTap(linkTapResults, MarkdownLink('foo', '/url')); @@ -2299,7 +2336,7 @@ void defineTests() { // Example 569 from GFM. 'shortcut reference links are case-insensitive', (WidgetTester tester) async { - const String data = '[Foo]\n\n[foo]: /url "title"'; + const data = '[Foo]\n\n[foo]: /url "title"'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2320,7 +2357,7 @@ void defineTests() { // Example 570 from GFM. 'shortcut reference link should preserve space after link text', (WidgetTester tester) async { - const String data = '[foo] bar\n\n[foo]: /url'; + const data = '[foo] bar\n\n[foo]: /url'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2333,7 +2370,7 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expectLinkTextSpan(span.children![0] as TextSpan, 'foo'); @@ -2341,7 +2378,8 @@ void defineTests() { expect(span.children![1], isA()); expect(span.children![1].toPlainText(), ' bar'); - expectTextSpanStyle(span.children![1] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![1] as TextSpan, null, FontWeight.normal); }, ); @@ -2349,7 +2387,7 @@ void defineTests() { // Example 571 from GFM. 'shortcut reference link backslash escape opening bracket to avoid link', (WidgetTester tester) async { - const String data = '\[foo]\n\n[foo]: /url "title"'; + const data = '\[foo]\n\n[foo]: /url "title"'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2374,7 +2412,7 @@ void defineTests() { // Example 572 from GFM. 'shortcut reference link text grouping has precedence over emphasis grouping', (WidgetTester tester) async { - const String data = '[foo*]: /url\n\n*[foo*]'; + const data = '[foo*]: /url\n\n*[foo*]'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2387,11 +2425,12 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expect(span.children![0], isA()); expect(span.children![0].toPlainText(), '*'); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); expectLinkTextSpan(span.children![1] as TextSpan, 'foo*'); expectLinkTap(linkTapResults, MarkdownLink('foo*', '/url')); @@ -2405,7 +2444,7 @@ void defineTests() { // Example 573 from GFM. 'full link reference takes precedence over shortcut link reference', (WidgetTester tester) async { - const String data = '[foo][bar]\n\n[foo]: /url1\n[bar]: /url2'; + const data = '[foo][bar]\n\n[foo]: /url1\n[bar]: /url2'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2426,7 +2465,7 @@ void defineTests() { // Example 574 from GFM. 'compact link reference takes precedence over shortcut link reference', (WidgetTester tester) async { - const String data = '[foo][]\n\n[foo]: /url1'; + const data = '[foo][]\n\n[foo]: /url1'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2447,7 +2486,7 @@ void defineTests() { // Example 575 from GFM. 'inline link reference, no link destination takes precedence over shortcut link reference', (WidgetTester tester) async { - const String data = '[foo]()\n\n[foo]: /url1'; + const data = '[foo]()\n\n[foo]: /url1'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2468,7 +2507,7 @@ void defineTests() { // Example 576 from GFM. 'inline link reference, invalid link destination is a link followed by text', (WidgetTester tester) async { - const String data = '[foo](not a link)\n\n[foo]: /url1'; + const data = '[foo](not a link)\n\n[foo]: /url1'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2481,7 +2520,7 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expectLinkTextSpan(span.children![0] as TextSpan, 'foo'); @@ -2489,7 +2528,8 @@ void defineTests() { expect(span.children![1], isA()); expect(span.children![1].toPlainText(), '(not a link)'); - expectTextSpanStyle(span.children![1] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![1] as TextSpan, null, FontWeight.normal); }, ); @@ -2497,7 +2537,7 @@ void defineTests() { // Example 577 from GFM. 'three sequential runs of square-bracketed text, normal text and a link reference', (WidgetTester tester) async { - const String data = '[foo][bar][baz]\n\n[baz]: /url'; + const data = '[foo][bar][baz]\n\n[baz]: /url'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2510,12 +2550,13 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expect(span.children![0], isA()); expect(span.children![0].toPlainText(), '[foo]'); - expectTextSpanStyle(span.children![0] as TextSpan, null, FontWeight.normal); + expectTextSpanStyle( + span.children![0] as TextSpan, null, FontWeight.normal); expectLinkTextSpan(span.children![1] as TextSpan, 'bar'); expectLinkTap(linkTapResults, MarkdownLink('bar', '/url')); @@ -2526,7 +2567,7 @@ void defineTests() { // Example 578 from GFM. 'three sequential runs of square-bracketed text, two link references', (WidgetTester tester) async { - const String data = '[foo][bar][baz]\n\n[baz]: /url1\n[bar]: /url2'; + const data = '[foo][bar][baz]\n\n[baz]: /url1\n[bar]: /url2'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2539,7 +2580,7 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expectLinkTextSpan(span.children![0] as TextSpan, 'foo'); @@ -2554,7 +2595,7 @@ void defineTests() { // Example 579 from GFM. 'full reference link followed by a shortcut reference link', (WidgetTester tester) async { - const String data = '[foo][bar][baz]\n\n[baz]: /url1\n[foo]: /url2'; + const data = '[foo][bar][baz]\n\n[baz]: /url1\n[foo]: /url2'; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -2567,7 +2608,7 @@ void defineTests() { ); final RichText textWidget = tester.widget(find.byType(RichText)); - final TextSpan span = textWidget.text as TextSpan; + final span = textWidget.text as TextSpan; expect(span.children!.length, 2); expect(span.children![0], isA()); expect(span.children![0].toPlainText(), '[foo]');