@@ -57,7 +57,9 @@ class CssBoxWidget extends StatelessWidget {
57
57
58
58
@override
59
59
Widget build (BuildContext context) {
60
- final markerBox = _generateMarkerBox (style);
60
+ final markerBox = style.listStylePosition == ListStylePosition .outside
61
+ ? _generateMarkerBoxSpan (style)
62
+ : null ;
61
63
62
64
return _CSSBoxRenderer (
63
65
width: style.width ?? Width .auto (),
@@ -80,7 +82,7 @@ class CssBoxWidget extends StatelessWidget {
80
82
padding: style.padding ?? EdgeInsets .zero,
81
83
child: child,
82
84
),
83
- if (markerBox != null ) markerBox,
85
+ if (markerBox != null ) Text . rich ( markerBox) ,
84
86
],
85
87
);
86
88
}
@@ -92,6 +94,15 @@ class CssBoxWidget extends StatelessWidget {
92
94
return Container ();
93
95
}
94
96
97
+ // Generate an inline marker box if the list-style-position is set to
98
+ // inside. Otherwise the marker box will be added elsewhere.
99
+ if (style.listStylePosition == ListStylePosition .inside) {
100
+ final inlineMarkerBox = _generateMarkerBoxSpan (style);
101
+ if (inlineMarkerBox != null ) {
102
+ children.insert (0 , inlineMarkerBox);
103
+ }
104
+ }
105
+
95
106
return Text .rich (
96
107
TextSpan (
97
108
style: style.generateTextStyle (),
@@ -129,17 +140,38 @@ class CssBoxWidget extends StatelessWidget {
129
140
);
130
141
}
131
142
132
- static Widget ? _generateMarkerBox (Style style) {
133
- if (style.display == Display .listItem &&
134
- style.listStylePosition == ListStylePosition .outside) {
135
- if (style.marker? .content.replacementContent? .isNotEmpty ?? false ) {
136
- return Text .rich (
137
- TextSpan (
138
- text: style.marker! .content.replacementContent! ,
139
- style: style.marker! .style? .generateTextStyle (),
143
+ static InlineSpan ? _generateMarkerBoxSpan (Style style) {
144
+ if (style.display == Display .listItem) {
145
+ // First handle listStyleImage
146
+ if (style.listStyleImage != null ) {
147
+ return WidgetSpan (
148
+ alignment: PlaceholderAlignment .middle,
149
+ child: Image .network (
150
+ style.listStyleImage! .uriText,
151
+ errorBuilder: (_, __, ___) {
152
+ if (style.marker? .content.replacementContent? .isNotEmpty ??
153
+ false ) {
154
+ return Text .rich (
155
+ TextSpan (
156
+ text: style.marker! .content.replacementContent! ,
157
+ style: style.marker! .style? .generateTextStyle (),
158
+ ),
159
+ );
160
+ }
161
+
162
+ return Container ();
163
+ },
140
164
),
141
165
);
142
166
}
167
+
168
+ // Display list marker with given style
169
+ if (style.marker? .content.replacementContent? .isNotEmpty ?? false ) {
170
+ return TextSpan (
171
+ text: style.marker! .content.replacementContent! ,
172
+ style: style.marker! .style? .generateTextStyle (),
173
+ );
174
+ }
143
175
}
144
176
145
177
return null ;
0 commit comments