代码拉取完成,页面将自动刷新
import 'package:flutter/material.dart';
import 'package:flutter_html/src/html_elements.dart';
import 'package:flutter_html/style.dart';
import 'package:html/dom.dart' as dom;
/// An [InteractableElement] is a [StyledElement] that takes user gestures (e.g. tap).
class InteractableElement extends StyledElement {
String? href;
InteractableElement({
required String name,
required List<StyledElement> children,
required Style style,
required this.href,
required dom.Node node,
required String elementId,
}) : super(name: name, children: children, style: style, node: node as dom.Element?, elementId: elementId);
}
/// A [Gesture] indicates the type of interaction by a user.
enum Gesture {
TAP,
}
StyledElement parseInteractableElement(
dom.Element element, List<StyledElement> children) {
switch (element.localName) {
case "a":
if (element.attributes.containsKey('href')) {
return InteractableElement(
name: element.localName!,
children: children,
href: element.attributes['href'],
style: Style(
color: Colors.blue,
textDecoration: TextDecoration.underline,
),
node: element,
elementId: element.id
);
}
// When <a> tag have no href, it must be non clickable and without decoration.
return StyledElement(
name: element.localName!,
children: children,
style: Style(),
node: element,
elementId: element.id,
);
/// will never be called, just to suppress missing return warning
default:
return InteractableElement(
name: element.localName!,
children: children,
node: element,
href: '',
style: Style(),
elementId: "[[No ID]]"
);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。