@@ -56,16 +56,19 @@ class CssBoxWidget extends StatelessWidget {
56
56
? _generateMarkerBoxSpan (style)
57
57
: null ;
58
58
59
+ final directionality = _checkTextDirection (context, textDirection);
60
+ final padding = style.padding? .toEdgeInsets (directionality);
61
+
59
62
return _CSSBoxRenderer (
60
63
width: style.width ?? Width .auto (),
61
64
height: style.height ?? Height .auto (),
62
- paddingSize: style. padding? .collapsedSize ?? Size .zero,
65
+ paddingSize: padding? .collapsedSize ?? Size .zero,
63
66
borderSize: style.border? .dimensions.collapsedSize ?? Size .zero,
64
67
margins: style.margin ?? Margins .zero,
65
68
display: style.display ?? Display .inline,
66
69
childIsReplaced: childIsReplaced,
67
70
emValue: _calculateEmValue (style, context),
68
- textDirection: _checkTextDirection (context, textDirection) ,
71
+ textDirection: directionality ,
69
72
shrinkWrap: shrinkWrap,
70
73
children: [
71
74
Container (
@@ -74,7 +77,7 @@ class CssBoxWidget extends StatelessWidget {
74
77
color: style.backgroundColor, //Colors the padding and content boxes
75
78
),
76
79
width: _shouldExpandToFillBlock () ? double .infinity : null ,
77
- padding: style. padding ?? EdgeInsets .zero ,
80
+ padding: padding,
78
81
child: top
79
82
? child
80
83
: MediaQuery (
@@ -253,10 +256,21 @@ class _CSSBoxRenderer extends MultiChildRenderObjectWidget {
253
256
}
254
257
255
258
Margins _preProcessMargins (Margins margins, bool shrinkWrap) {
256
- Margin leftMargin = margins.left ?? Margin .zero ();
257
- Margin rightMargin = margins.right ?? Margin .zero ();
258
- Margin topMargin = margins.top ?? Margin .zero ();
259
- Margin bottomMargin = margins.bottom ?? Margin .zero ();
259
+ late Margin leftMargin;
260
+ late Margin rightMargin;
261
+ Margin topMargin = margins.top ?? margins.blockStart ?? Margin .zero ();
262
+ Margin bottomMargin = margins.bottom ?? margins.blockEnd ?? Margin .zero ();
263
+
264
+ switch (textDirection) {
265
+ case TextDirection .rtl:
266
+ leftMargin = margins.left ?? margins.inlineEnd ?? Margin .zero ();
267
+ rightMargin = margins.right ?? margins.inlineStart ?? Margin .zero ();
268
+ break ;
269
+ case TextDirection .ltr:
270
+ leftMargin = margins.left ?? margins.inlineStart ?? Margin .zero ();
271
+ rightMargin = margins.right ?? margins.inlineEnd ?? Margin .zero ();
272
+ break ;
273
+ }
260
274
261
275
//Preprocess margins to a pixel value
262
276
leftMargin.normalize (emValue);
@@ -593,7 +607,20 @@ class _RenderCSSBox extends RenderBox
593
607
final offsetHeight = distance -
594
608
(markerBox.getDistanceToBaseline (TextBaseline .alphabetic) ??
595
609
markerBox.size.height);
596
- markerBoxParentData.offset = Offset (- markerBox.size.width, offsetHeight);
610
+ switch (_textDirection) {
611
+ case TextDirection .rtl:
612
+ markerBoxParentData.offset = Offset (
613
+ child.size.width,
614
+ offsetHeight,
615
+ );
616
+ break ;
617
+ case TextDirection .ltr:
618
+ markerBoxParentData.offset = Offset (
619
+ - markerBox.size.width,
620
+ offsetHeight,
621
+ );
622
+ break ;
623
+ }
597
624
}
598
625
}
599
626
@@ -701,10 +728,11 @@ class _RenderCSSBox extends RenderBox
701
728
}
702
729
703
730
return Margins (
704
- left: marginLeft,
705
- right: marginRight,
706
- top: margins.top,
707
- bottom: margins.bottom);
731
+ left: marginLeft,
732
+ right: marginRight,
733
+ top: margins.top,
734
+ bottom: margins.bottom,
735
+ );
708
736
}
709
737
710
738
@override
0 commit comments