Skip to content

Commit 6e0ebe3

Browse files
authored
Add support for list-style-type: none (#847)
Related to #811
1 parent 1e10781 commit 6e0ebe3

File tree

4 files changed

+57
-39
lines changed

4 files changed

+57
-39
lines changed

demo_app/pubspec.lock

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ packages:
4242
name: audio_session
4343
url: "https://pub.dartlang.org"
4444
source: hosted
45-
version: "0.1.10"
45+
version: "0.1.13"
4646
boolean_selector:
4747
dependency: transitive
4848
description:
@@ -56,7 +56,7 @@ packages:
5656
name: cached_network_image
5757
url: "https://pub.dartlang.org"
5858
source: hosted
59-
version: "3.2.2"
59+
version: "3.2.3"
6060
cached_network_image_platform_interface:
6161
dependency: transitive
6262
description:
@@ -77,7 +77,7 @@ packages:
7777
name: carousel_slider
7878
url: "https://pub.dartlang.org"
7979
source: hosted
80-
version: "4.1.1"
80+
version: "4.2.1"
8181
characters:
8282
dependency: transitive
8383
description:
@@ -91,7 +91,7 @@ packages:
9191
name: chewie
9292
url: "https://pub.dartlang.org"
9393
source: hosted
94-
version: "1.3.5"
94+
version: "1.3.6"
9595
clock:
9696
dependency: transitive
9797
description:
@@ -192,7 +192,7 @@ packages:
192192
name: flutter_svg
193193
url: "https://pub.dartlang.org"
194194
source: hosted
195-
version: "1.1.5"
195+
version: "1.1.6"
196196
flutter_test:
197197
dependency: "direct dev"
198198
description: flutter
@@ -209,7 +209,7 @@ packages:
209209
path: "../packages/enhanced"
210210
relative: true
211211
source: path
212-
version: "0.9.0+1"
212+
version: "0.9.0+2"
213213
flutter_widget_from_html_core:
214214
dependency: "direct main"
215215
description:
@@ -277,7 +277,7 @@ packages:
277277
path: "../packages/fwfh_webview"
278278
relative: true
279279
source: path
280-
version: "0.6.2+5"
280+
version: "0.7.0"
281281
glob:
282282
dependency: transitive
283283
description:
@@ -366,7 +366,7 @@ packages:
366366
name: lint
367367
url: "https://pub.dartlang.org"
368368
source: hosted
369-
version: "1.10.0"
369+
version: "2.0.1"
370370
logging:
371371
dependency: transitive
372372
description:
@@ -408,7 +408,7 @@ packages:
408408
name: mime
409409
url: "https://pub.dartlang.org"
410410
source: hosted
411-
version: "1.0.2"
411+
version: "1.0.3"
412412
nested:
413413
dependency: transitive
414414
description:
@@ -471,7 +471,7 @@ packages:
471471
name: path_provider_android
472472
url: "https://pub.dartlang.org"
473473
source: hosted
474-
version: "2.0.20"
474+
version: "2.0.22"
475475
path_provider_ios:
476476
dependency: transitive
477477
description:
@@ -562,21 +562,21 @@ packages:
562562
name: provider
563563
url: "https://pub.dartlang.org"
564564
source: hosted
565-
version: "6.0.4"
565+
version: "6.0.5"
566566
pub_semver:
567567
dependency: transitive
568568
description:
569569
name: pub_semver
570570
url: "https://pub.dartlang.org"
571571
source: hosted
572-
version: "2.1.2"
572+
version: "2.1.3"
573573
rxdart:
574574
dependency: transitive
575575
description:
576576
name: rxdart
577577
url: "https://pub.dartlang.org"
578578
source: hosted
579-
version: "0.27.5"
579+
version: "0.27.7"
580580
shelf:
581581
dependency: transitive
582582
description:
@@ -604,7 +604,7 @@ packages:
604604
name: shelf_web_socket
605605
url: "https://pub.dartlang.org"
606606
source: hosted
607-
version: "1.0.2"
607+
version: "1.0.3"
608608
sky_engine:
609609
dependency: transitive
610610
description: flutter
@@ -637,14 +637,14 @@ packages:
637637
name: sqflite
638638
url: "https://pub.dartlang.org"
639639
source: hosted
640-
version: "2.1.0+1"
640+
version: "2.2.2"
641641
sqflite_common:
642642
dependency: transitive
643643
description:
644644
name: sqflite_common
645645
url: "https://pub.dartlang.org"
646646
source: hosted
647-
version: "2.3.0"
647+
version: "2.4.0+2"
648648
stack_trace:
649649
dependency: transitive
650650
description:
@@ -721,14 +721,14 @@ packages:
721721
name: url_launcher
722722
url: "https://pub.dartlang.org"
723723
source: hosted
724-
version: "6.1.6"
724+
version: "6.1.7"
725725
url_launcher_android:
726726
dependency: transitive
727727
description:
728728
name: url_launcher_android
729729
url: "https://pub.dartlang.org"
730730
source: hosted
731-
version: "6.0.19"
731+
version: "6.0.22"
732732
url_launcher_ios:
733733
dependency: transitive
734734
description:
@@ -777,7 +777,7 @@ packages:
777777
name: uuid
778778
url: "https://pub.dartlang.org"
779779
source: hosted
780-
version: "3.0.6"
780+
version: "3.0.7"
781781
vector_math:
782782
dependency: transitive
783783
description:
@@ -791,35 +791,35 @@ packages:
791791
name: video_player
792792
url: "https://pub.dartlang.org"
793793
source: hosted
794-
version: "2.4.7"
794+
version: "2.4.10"
795795
video_player_android:
796796
dependency: transitive
797797
description:
798798
name: video_player_android
799799
url: "https://pub.dartlang.org"
800800
source: hosted
801-
version: "2.3.9"
801+
version: "2.3.10"
802802
video_player_avfoundation:
803803
dependency: transitive
804804
description:
805805
name: video_player_avfoundation
806806
url: "https://pub.dartlang.org"
807807
source: hosted
808-
version: "2.3.7"
808+
version: "2.3.8"
809809
video_player_platform_interface:
810810
dependency: transitive
811811
description:
812812
name: video_player_platform_interface
813813
url: "https://pub.dartlang.org"
814814
source: hosted
815-
version: "5.1.4"
815+
version: "6.0.1"
816816
video_player_web:
817817
dependency: transitive
818818
description:
819819
name: video_player_web
820820
url: "https://pub.dartlang.org"
821821
source: hosted
822-
version: "2.0.12"
822+
version: "2.0.13"
823823
vm_service:
824824
dependency: transitive
825825
description:
@@ -924,7 +924,7 @@ packages:
924924
name: win32
925925
url: "https://pub.dartlang.org"
926926
source: hosted
927-
version: "3.0.1"
927+
version: "3.1.3"
928928
xdg_directories:
929929
dependency: transitive
930930
description:

packages/core/lib/src/core_widget_factory.dart

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -296,18 +296,26 @@ class WidgetFactory {
296296
) {
297297
final text = getListMarkerText(listStyleType, index);
298298
final style = tsh.style;
299-
return text.isNotEmpty
300-
? RichText(
301-
maxLines: 1,
302-
softWrap: false,
303-
text: TextSpan(style: style, text: text),
304-
textDirection: tsh.textDirection,
305-
)
306-
: listStyleType == kCssListStyleTypeCircle
307-
? HtmlListMarker.circle(style)
308-
: listStyleType == kCssListStyleTypeSquare
309-
? HtmlListMarker.square(style)
310-
: HtmlListMarker.disc(style);
299+
if (text.isNotEmpty) {
300+
return RichText(
301+
maxLines: 1,
302+
softWrap: false,
303+
text: TextSpan(style: style, text: text),
304+
textDirection: tsh.textDirection,
305+
);
306+
}
307+
308+
switch (listStyleType) {
309+
case kCssListStyleTypeCircle:
310+
return HtmlListMarker.circle(style);
311+
case kCssListStyleTypeNone:
312+
return null;
313+
case kCssListStyleTypeSquare:
314+
return HtmlListMarker.square(style);
315+
case kCssListStyleTypeDisc:
316+
default:
317+
return HtmlListMarker.disc(style);
318+
}
311319
}
312320

313321
/// Builds [Padding].
@@ -490,9 +498,10 @@ class WidgetFactory {
490498
case kCssListStyleTypeRomanUpper:
491499
final roman = _getListMarkerRoman(i);
492500
return roman != null ? '$roman.' : '';
501+
case kCssListStyleTypeNone:
502+
default:
503+
return '';
493504
}
494-
495-
return '';
496505
}
497506

498507
String? _getListMarkerRoman(int i) {

packages/core/lib/src/internal/ops/tag_li.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const kCssListStyleTypeAlphaLatinUpper = 'upper-latin';
1919
const kCssListStyleTypeCircle = 'circle';
2020
const kCssListStyleTypeDecimal = 'decimal';
2121
const kCssListStyleTypeDisc = 'disc';
22+
const kCssListStyleTypeNone = 'none';
2223
const kCssListStyleTypeRomanLower = 'lower-roman';
2324
const kCssListStyleTypeRomanUpper = 'upper-roman';
2425
const kCssListStyleTypeSquare = 'square';

packages/core/test/tag_li_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,12 @@ Future<void> main() async {
315315
expect(explained, equals(padding(item(circle, 'Foo'))));
316316
});
317317

318+
testWidgets('renders none', (WidgetTester tester) async {
319+
const html = '<ul style="list-style-type: none"><li>Foo</li></ul>';
320+
final explained = await explain(tester, html);
321+
expect(explained, equals(padding('[RichText:(:Foo)]')));
322+
});
323+
318324
testWidgets('renders square', (WidgetTester tester) async {
319325
const html = '<ul style="list-style-type: square"><li>Foo</li></ul>';
320326
final explained = await explain(tester, html);
@@ -325,6 +331,7 @@ Future<void> main() async {
325331
const html = '''
326332
<ul style="list-style-type: circle">
327333
<li style="list-style-type: disc"">disc</li>
334+
<li style="list-style-type: none"">none</li>
328335
<li style="list-style-type: square">square</li>
329336
<li>circle</li>
330337
<ul>
@@ -336,6 +343,7 @@ Future<void> main() async {
336343
padding(
337344
list([
338345
item(disc, 'disc'),
346+
'[RichText:(:none)]',
339347
item(square, 'square'),
340348
item(circle, 'circle'),
341349
]),

0 commit comments

Comments
 (0)