@@ -5,7 +5,8 @@ import 'package:html/dom.dart' as dom;
5
5
6
6
typedef CustomRender = Widget Function (dom.Node node, List <Widget > children);
7
7
typedef OnLinkTap = void Function (String url);
8
- const OFFSET_TAGS_FONT_SIZE_FACTOR = 0.7 ; //The ratio of the parent font for each of the offset tags: sup or sub
8
+ const OFFSET_TAGS_FONT_SIZE_FACTOR =
9
+ 0.7 ; //The ratio of the parent font for each of the offset tags: sup or sub
9
10
10
11
class LinkTextSpan extends TextSpan {
11
12
// Beware!
@@ -757,7 +758,7 @@ class HtmlOldParser extends StatelessWidget {
757
758
this .onLinkTap,
758
759
this .renderNewlines = false ,
759
760
this .customRender,
760
- this .blockSpacing = 14.0 ,
761
+ this .blockSpacing,
761
762
this .html,
762
763
});
763
764
@@ -868,7 +869,7 @@ class HtmlOldParser extends StatelessWidget {
868
869
Widget _parseNode (dom.Node node) {
869
870
if (customRender != null ) {
870
871
final Widget customWidget =
871
- customRender (node, _parseNodeList (node.nodes));
872
+ customRender (node, _parseNodeList (node.nodes));
872
873
if (customWidget != null ) {
873
874
return customWidget;
874
875
}
@@ -981,7 +982,8 @@ class HtmlOldParser extends StatelessWidget {
981
982
);
982
983
case "blockquote" :
983
984
return Padding (
984
- padding: EdgeInsets .fromLTRB (40.0 , blockSpacing, 40.0 , blockSpacing),
985
+ padding:
986
+ EdgeInsets .fromLTRB (40.0 , blockSpacing, 40.0 , blockSpacing),
985
987
child: Container (
986
988
width: width,
987
989
child: Wrap (
@@ -1104,7 +1106,8 @@ class HtmlOldParser extends StatelessWidget {
1104
1106
);
1105
1107
case "figure" :
1106
1108
return Padding (
1107
- padding: EdgeInsets .fromLTRB (40.0 , blockSpacing, 40.0 , blockSpacing),
1109
+ padding:
1110
+ EdgeInsets .fromLTRB (40.0 , blockSpacing, 40.0 , blockSpacing),
1108
1111
child: Column (
1109
1112
children: _parseNodeList (node.nodes),
1110
1113
crossAxisAlignment: CrossAxisAlignment .center,
@@ -1282,8 +1285,7 @@ class HtmlOldParser extends StatelessWidget {
1282
1285
mark,
1283
1286
Wrap (
1284
1287
crossAxisAlignment: WrapCrossAlignment .center,
1285
- children: _parseNodeList (node.nodes)
1286
- )
1288
+ children: _parseNodeList (node.nodes))
1287
1289
],
1288
1290
),
1289
1291
);
@@ -1334,7 +1336,7 @@ class HtmlOldParser extends StatelessWidget {
1334
1336
width: width,
1335
1337
child: Wrap (
1336
1338
crossAxisAlignment: WrapCrossAlignment .center,
1337
- alignment: WrapAlignment .start, //@ominibyte Added this for when the line breaks. I think it looks better
1339
+ alignment: WrapAlignment .start,
1338
1340
children: _parseNodeList (node.nodes),
1339
1341
),
1340
1342
),
@@ -1433,19 +1435,32 @@ class HtmlOldParser extends StatelessWidget {
1433
1435
);
1434
1436
case "sub" :
1435
1437
case "sup" :
1436
- //Use builder to capture the parent font to inherit the font styles
1437
- return Builder (builder: (BuildContext context){
1438
+ //Use builder to capture the parent font to inherit the font styles
1439
+ return Builder (builder: (BuildContext context) {
1438
1440
final DefaultTextStyle parent = DefaultTextStyle .of (context);
1439
1441
TextStyle parentStyle = parent.style;
1440
1442
1441
- var painter = new TextPainter (text: new TextSpan (text: node.text, style: parentStyle,), textDirection: TextDirection .ltr);
1443
+ var painter = new TextPainter (
1444
+ text: new TextSpan (
1445
+ text: node.text,
1446
+ style: parentStyle,
1447
+ ),
1448
+ textDirection: TextDirection .ltr);
1442
1449
painter.layout ();
1443
1450
//print(painter.size);
1444
1451
1445
1452
//Get the height from the default text
1446
- var height = painter.size.height * 1.35 ; //compute a higher height for the text to increase the offset of the Positioned text
1447
-
1448
- painter = new TextPainter (text: new TextSpan (text: node.text, style: parentStyle.merge (TextStyle (fontSize: parentStyle.fontSize * OFFSET_TAGS_FONT_SIZE_FACTOR )),), textDirection: TextDirection .ltr);
1453
+ var height = painter.size.height *
1454
+ 1.35 ; //compute a higher height for the text to increase the offset of the Positioned text
1455
+
1456
+ painter = new TextPainter (
1457
+ text: new TextSpan (
1458
+ text: node.text,
1459
+ style: parentStyle.merge (TextStyle (
1460
+ fontSize:
1461
+ parentStyle.fontSize * OFFSET_TAGS_FONT_SIZE_FACTOR )),
1462
+ ),
1463
+ textDirection: TextDirection .ltr);
1449
1464
painter.layout ();
1450
1465
//print(painter.size);
1451
1466
@@ -1463,14 +1478,19 @@ class HtmlOldParser extends StatelessWidget {
1463
1478
children: [
1464
1479
//The Stack needs a non-positioned object for the next widget to respect the space so we create
1465
1480
//a sized box to fill the required space
1466
- SizedBox (width: width, height: height,),
1481
+ SizedBox (
1482
+ width: width,
1483
+ height: height,
1484
+ ),
1467
1485
DefaultTextStyle .merge (
1468
1486
child: Positioned (
1469
1487
child: Wrap (children: _parseNodeList (node.nodes)),
1470
1488
bottom: node.localName == "sub" ? 0 : null ,
1471
1489
top: node.localName == "sub" ? null : 0 ,
1472
1490
),
1473
- style: TextStyle (fontSize: parentStyle.fontSize * OFFSET_TAGS_FONT_SIZE_FACTOR ),
1491
+ style: TextStyle (
1492
+ fontSize: parentStyle.fontSize *
1493
+ OFFSET_TAGS_FONT_SIZE_FACTOR ),
1474
1494
)
1475
1495
],
1476
1496
)
@@ -1501,7 +1521,7 @@ class HtmlOldParser extends StatelessWidget {
1501
1521
),
1502
1522
);
1503
1523
case "template" :
1504
- //Not usually displayed in HTML
1524
+ //Not usually displayed in HTML
1505
1525
return Container ();
1506
1526
case "tfoot" :
1507
1527
return Column (
@@ -1579,7 +1599,7 @@ class HtmlOldParser extends StatelessWidget {
1579
1599
return Wrap ();
1580
1600
}
1581
1601
if (node.text.trim () == "" && node.text.indexOf (" " ) != - 1 ) {
1582
- node.text = "" ; //@ominibyte Looks better without the space
1602
+ node.text = " " ;
1583
1603
}
1584
1604
1585
1605
String finalText = trimStringHtml (node.text);
0 commit comments