Skip to content

Commit a89773a

Browse files
committed
Fix analysis hints in lib/
1 parent 2db8818 commit a89773a

13 files changed

+554
-638
lines changed

lib/custom_render.dart

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ CustomRenderMatcher tagMatcher(String tag) => (context) {
1616
};
1717

1818
CustomRenderMatcher blockElementMatcher() => (context) {
19-
return (context.tree.style.display == Display.BLOCK ||
20-
context.tree.style.display == Display.INLINE_BLOCK) &&
19+
return (context.tree.style.display == Display.block ||
20+
context.tree.style.display == Display.inlineBlock) &&
2121
(context.tree.children.isNotEmpty ||
2222
context.tree.element?.localName == "hr");
2323
};
2424

2525
CustomRenderMatcher listElementMatcher() => (context) {
26-
return context.tree.style.display == Display.LIST_ITEM;
26+
return context.tree.style.display == Display.listItem;
2727
};
2828

2929
CustomRenderMatcher replacedElementMatcher() => (context) {
@@ -44,7 +44,7 @@ CustomRenderMatcher dataUriMatcher(
4444
};
4545

4646
CustomRenderMatcher networkSourceMatcher({
47-
List<String> schemas: const ["https", "http"],
47+
List<String> schemas = const ["https", "http"],
4848
List<String>? domains,
4949
String? extension,
5050
}) =>
@@ -81,7 +81,7 @@ CustomRenderMatcher layoutElementMatcher() => (context) {
8181

8282
CustomRenderMatcher verticalAlignMatcher() => (context) {
8383
return context.tree.style.verticalAlign != null &&
84-
context.tree.style.verticalAlign != VerticalAlign.BASELINE;
84+
context.tree.style.verticalAlign != VerticalAlign.baseline;
8585
};
8686

8787
CustomRenderMatcher fallbackMatcher() => (context) {
@@ -120,10 +120,10 @@ CustomRender blockElementRender({Style? style, List<InlineSpan>? children}) =>
120120
.expandIndexed((i, childTree) => [
121121
context.parser.parseTree(context, childTree),
122122
if (i != context.tree.children.length - 1 &&
123-
childTree.style.display == Display.BLOCK &&
123+
childTree.style.display == Display.block &&
124124
childTree.element?.localName != "html" &&
125125
childTree.element?.localName != "body")
126-
TextSpan(text: "\n"),
126+
const TextSpan(text: "\n"),
127127
])
128128
.toList(),
129129
);
@@ -136,17 +136,17 @@ CustomRender blockElementRender({Style? style, List<InlineSpan>? children}) =>
136136
style: style ?? context.tree.style,
137137
shrinkWrap: context.parser.shrinkWrap,
138138
childIsReplaced:
139-
REPLACED_EXTERNAL_ELEMENTS.contains(context.tree.name),
139+
HtmlElements.replacedExternalElements.contains(context.tree.name),
140140
children: children ??
141141
context.tree.children
142142
.expandIndexed((i, childTree) => [
143143
context.parser.parseTree(context, childTree),
144144
//TODO can this newline be added in a different step?
145145
if (i != context.tree.children.length - 1 &&
146-
childTree.style.display == Display.BLOCK &&
146+
childTree.style.display == Display.block &&
147147
childTree.element?.localName != "html" &&
148148
childTree.element?.localName != "body")
149-
TextSpan(text: "\n"),
149+
const TextSpan(text: "\n"),
150150
])
151151
.toList(),
152152
),
@@ -168,7 +168,7 @@ CustomRender listElementRender(
168168
children: [
169169
(style?.listStylePosition ??
170170
context.tree.style.listStylePosition) ==
171-
ListStylePosition.OUTSIDE
171+
ListStylePosition.outside
172172
? Padding(
173173
padding: style?.padding?.nonNegative ??
174174
context.tree.style.padding?.nonNegative ??
@@ -185,15 +185,15 @@ CustomRender listElementRender(
185185
: 0.0),
186186
child:
187187
style?.markerContent ?? context.style.markerContent)
188-
: Container(height: 0, width: 0),
189-
Text("\u0020",
188+
: const SizedBox(height: 0, width: 0),
189+
const Text("\u0020",
190190
textAlign: TextAlign.right,
191191
style: TextStyle(fontWeight: FontWeight.w400)),
192192
Expanded(
193193
child: Padding(
194194
padding: (style?.listStylePosition ??
195195
context.tree.style.listStylePosition) ==
196-
ListStylePosition.INSIDE
196+
ListStylePosition.inside
197197
? EdgeInsets.only(
198198
left: (style?.direction ??
199199
context.tree.style.direction) !=
@@ -214,13 +214,13 @@ CustomRender listElementRender(
214214
..insertAll(
215215
0,
216216
context.tree.style.listStylePosition ==
217-
ListStylePosition.INSIDE
217+
ListStylePosition.inside
218218
? [
219219
WidgetSpan(
220220
alignment: PlaceholderAlignment.middle,
221221
child: style?.markerContent ??
222222
context.style.markerContent ??
223-
Container(height: 0, width: 0))
223+
const SizedBox(height: 0, width: 0))
224224
]
225225
: []),
226226
style: style ?? context.style,
@@ -370,16 +370,16 @@ CustomRender networkImageRender({
370370
if (!completer.isCompleted) {
371371
context.parser.cachedImageSizes[src] = size;
372372
completer.complete(size);
373-
image.image.resolve(ImageConfiguration()).removeListener(listener!);
373+
image.image.resolve(const ImageConfiguration()).removeListener(listener!);
374374
}
375375
}, onError: (object, stacktrace) {
376376
if (!completer.isCompleted) {
377377
completer.completeError(object);
378-
image.image.resolve(ImageConfiguration()).removeListener(listener!);
378+
image.image.resolve(const ImageConfiguration()).removeListener(listener!);
379379
}
380380
});
381381

382-
image.image.resolve(ImageConfiguration()).addListener(listener);
382+
image.image.resolve(const ImageConfiguration()).addListener(listener);
383383
}
384384
final attributes =
385385
context.tree.element!.attributes.cast<String, String>();
@@ -487,12 +487,12 @@ CustomRender fallbackRender({Style? style, List<InlineSpan>? children}) =>
487487
children: context.tree.children
488488
.expand((tree) => [
489489
context.parser.parseTree(context, tree),
490-
if (tree.style.display == Display.BLOCK &&
490+
if (tree.style.display == Display.block &&
491491
tree.element?.parent?.localName != "th" &&
492492
tree.element?.parent?.localName != "td" &&
493493
tree.element?.localName != "html" &&
494494
tree.element?.localName != "body")
495-
TextSpan(text: "\n"),
495+
const TextSpan(text: "\n"),
496496
])
497497
.toList(),
498498
));
@@ -516,8 +516,8 @@ Map<CustomRenderMatcher, CustomRender> generateDefaultRenders() {
516516
List<InlineSpan> _getListElementChildren(
517517
ListStylePosition? position, Function() buildChildren) {
518518
List<InlineSpan> children = buildChildren.call();
519-
if (position == ListStylePosition.INSIDE) {
520-
final tabSpan = WidgetSpan(
519+
if (position == ListStylePosition.inside) {
520+
const tabSpan = WidgetSpan(
521521
child: Text("\t",
522522
textAlign: TextAlign.right,
523523
style: TextStyle(fontWeight: FontWeight.w400)),
@@ -567,13 +567,13 @@ InlineSpan _getInteractableChildren(RenderContext context,
567567
}
568568

569569
final _dataUriFormat = RegExp(
570-
"^(?<scheme>data):(?<mime>image\/[\\w\+\-\.]+)(?<encoding>;base64)?\,(?<data>.*)");
570+
"^(?<scheme>data):(?<mime>image\\/[\\w\\+\\-\\.]+)(?<encoding>;base64)?\\,(?<data>.*)");
571571

572572
double _getVerticalOffset(StyledElement tree) {
573573
switch (tree.style.verticalAlign) {
574-
case VerticalAlign.SUB:
574+
case VerticalAlign.sub:
575575
return tree.style.fontSize!.value / 2.5;
576-
case VerticalAlign.SUPER:
576+
case VerticalAlign.sup:
577577
return tree.style.fontSize!.value / -2.5;
578578
default:
579579
return 0;
@@ -618,5 +618,5 @@ double _aspectRatio(
618618

619619
extension ClampedEdgeInsets on EdgeInsetsGeometry {
620620
EdgeInsetsGeometry get nonNegative =>
621-
this.clamp(EdgeInsets.zero, const EdgeInsets.all(double.infinity));
621+
clamp(EdgeInsets.zero, const EdgeInsets.all(double.infinity));
622622
}

lib/flutter_html.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class Html extends StatefulWidget {
8282
this.style = const {},
8383
}) : data = null,
8484
assert(document != null),
85-
this.documentElement = document!.documentElement,
85+
documentElement = document!.documentElement,
8686
_anchorKey = anchorKey ?? GlobalKey(),
8787
super(key: key);
8888

@@ -143,13 +143,13 @@ class Html extends StatefulWidget {
143143
/// An API that allows you to override the default style for any HTML element
144144
final Map<String, Style> style;
145145

146-
static List<String> get tags => new List<String>.from(STYLED_ELEMENTS)
147-
..addAll(INTERACTABLE_ELEMENTS)
148-
..addAll(REPLACED_ELEMENTS)
149-
..addAll(LAYOUT_ELEMENTS)
150-
..addAll(TABLE_CELL_ELEMENTS)
151-
..addAll(TABLE_DEFINITION_ELEMENTS)
152-
..addAll(EXTERNAL_ELEMENTS);
146+
static List<String> get tags => List<String>.from(HtmlElements.styledElements)
147+
..addAll(HtmlElements.interactableElements)
148+
..addAll(HtmlElements.replacedElements)
149+
..addAll(HtmlElements.layoutElements)
150+
..addAll(HtmlElements.tableCellElements)
151+
..addAll(HtmlElements.tableDefinitionElements)
152+
..addAll(HtmlElements.externalElements);
153153

154154
@override
155155
State<StatefulWidget> createState() => _HtmlState();
@@ -263,7 +263,7 @@ class SelectableHtml extends StatefulWidget {
263263
this.scrollPhysics,
264264
}) : data = null,
265265
assert(document != null),
266-
this.documentElement = document!.documentElement,
266+
documentElement = document!.documentElement,
267267
_anchorKey = anchorKey ?? GlobalKey(),
268268
super(key: key);
269269

@@ -327,7 +327,7 @@ class SelectableHtml extends StatefulWidget {
327327
/// fallback to the default rendering.
328328
final Map<CustomRenderMatcher, SelectableCustomRender> customRenders;
329329

330-
static List<String> get tags => new List<String>.from(SELECTABLE_ELEMENTS);
330+
static List<String> get tags => List<String>.from(HtmlElements.selectableElements);
331331

332332
@override
333333
State<StatefulWidget> createState() => _SelectableHtmlState();
@@ -346,7 +346,7 @@ class _SelectableHtmlState extends State<SelectableHtml> {
346346

347347
@override
348348
Widget build(BuildContext context) {
349-
return Container(
349+
return SizedBox(
350350
width: widget.shrinkWrap ? null : MediaQuery.of(context).size.width,
351351
child: HtmlParser(
352352
key: widget._anchorKey,

0 commit comments

Comments
 (0)