Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example/ios/Flutter/.last_build_id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b3c4eea2dd8d0e9a7588ec1d67cf9bef
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 7fb83752f59ead6285236625b82473f90b1cb932

COCOAPODS: 1.8.3
COCOAPODS: 1.9.1
3 changes: 0 additions & 3 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@
/* Begin XCBuildConfiguration section */
249021D3217E4FDB00AE95B9 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -386,7 +385,6 @@
};
97C147031CF9000F007C117D /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -442,7 +440,6 @@
};
97C147041CF9000F007C117D /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down
51 changes: 15 additions & 36 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.0"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -50,6 +36,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0+1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
collection:
dependency: transitive
description:
Expand All @@ -64,13 +57,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
css_colors:
dependency: transitive
description:
Expand All @@ -92,6 +78,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -128,13 +121,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.14.0+3"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.12"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -162,7 +148,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
version: "1.7.0"
path_drawing:
dependency: transitive
description:
Expand All @@ -184,13 +170,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
screen:
dependency: transitive
description:
Expand Down
43 changes: 21 additions & 22 deletions lib/html_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ import 'package:html/dom.dart' as dom;
import 'package:html/parser.dart' as htmlparser;

typedef OnTap = void Function(String url);
typedef CustomRender = Widget Function(
RenderContext context,
Widget parsedChild,
Map<String, String> attributes,
dom.Element element,
);
typedef CustomRender = dynamic Function(RenderContext context,
Widget parsedChild, Map<String, String> attributes, dom.Element element);

class HtmlParser extends StatelessWidget {
final String htmlData;
Expand Down Expand Up @@ -224,27 +220,30 @@ class HtmlParser extends StatelessWidget {
);

if (customRender?.containsKey(tree.name) ?? false) {
return WidgetSpan(
child: ContainerSpan(
final render = customRender[tree.name].call(
newContext,
ContainerSpan(
newContext: newContext,
style: tree.style,
shrinkWrap: context.parser.shrinkWrap,
child: customRender[tree.name].call(
newContext,
ContainerSpan(
newContext: newContext,
style: tree.style,
shrinkWrap: context.parser.shrinkWrap,
children: tree.children
?.map((tree) => parseTree(newContext, tree))
?.toList() ??
[],
),
tree.attributes,
tree.element,
),
children: tree.children
?.map((tree) => parseTree(newContext, tree))
?.toList() ??
[],
),
tree.attributes,
tree.element,
);
return render is InlineSpan
? render
: WidgetSpan(
child: ContainerSpan(
newContext: newContext,
style: tree.style,
shrinkWrap: context.parser.shrinkWrap,
child: render,
),
);
}

//Return the correct InlineSpan based on the element type.
Expand Down
14 changes: 13 additions & 1 deletion lib/style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ class Style {
/// Inherited: no,
/// Default: Unspecified (null),
double height;

/// CSS attribute "`line-height`"
///
/// Inherited: yes
/// Default: Unspecifed (null),
double lineHeight;

/// CSS attribute "`letter-spacing`"
///
Expand Down Expand Up @@ -170,6 +176,7 @@ class Style {
this.fontStyle,
this.fontWeight,
this.height,
this.lineHeight,
this.letterSpacing,
this.listStyleType,
this.padding,
Expand Down Expand Up @@ -212,9 +219,9 @@ class Style {
letterSpacing: letterSpacing,
shadows: textShadow,
wordSpacing: wordSpacing,
height: lineHeight,
//TODO background
//TODO textBaseline
//TODO height
);
}

Expand All @@ -237,6 +244,7 @@ class Style {
fontStyle: other.fontStyle,
fontWeight: other.fontWeight,
height: other.height,
lineHeight: other.lineHeight,
letterSpacing: other.letterSpacing,
listStyleType: other.listStyleType,
padding: other.padding,
Expand Down Expand Up @@ -280,6 +288,7 @@ class Style {
textShadow: child.textShadow ?? textShadow,
whiteSpace: child.whiteSpace ?? whiteSpace,
wordSpacing: child.wordSpacing ?? wordSpacing,
lineHeight: child.lineHeight ?? lineHeight,
);
}

Expand All @@ -295,6 +304,7 @@ class Style {
FontWeight fontWeight,
double height,
double letterSpacing,
double lineHeight,
ListStyleType listStyleType,
EdgeInsets padding,
EdgeInsets margin,
Expand Down Expand Up @@ -325,6 +335,7 @@ class Style {
fontStyle: fontStyle ?? this.fontStyle,
fontWeight: fontWeight ?? this.fontWeight,
height: height ?? this.height,
lineHeight: lineHeight ?? this.lineHeight,
letterSpacing: letterSpacing ?? this.letterSpacing,
listStyleType: listStyleType ?? this.listStyleType,
padding: padding ?? this.padding,
Expand Down Expand Up @@ -361,6 +372,7 @@ class Style {
this.fontStyle = textStyle.fontStyle;
this.fontWeight = textStyle.fontWeight;
this.letterSpacing = textStyle.letterSpacing;
this.lineHeight = textStyle.height;
this.textShadow = textStyle.shadows;
this.wordSpacing = textStyle.wordSpacing;
}
Expand Down
51 changes: 15 additions & 36 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.0"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -50,6 +36,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0+1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
collection:
dependency: transitive
description:
Expand All @@ -64,13 +57,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
css_colors:
dependency: "direct main"
description:
Expand All @@ -85,6 +71,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.1"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -114,13 +107,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.14.0+3"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.12"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -148,7 +134,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
version: "1.7.0"
path_drawing:
dependency: transitive
description:
Expand All @@ -170,13 +156,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
screen:
dependency: transitive
description:
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ dependencies:
css_colors: ^1.0.2

# Plugins for rendering the <video> tag.
video_player: ^0.10.10
video_player: ^0.10.11+2
chewie: ^0.9.10

# Plugin for rendering the <iframe> tag.
webview_flutter: ^0.3.21
webview_flutter: ^1.0.3

# Plugins for rendering the <audio> tag.
chewie_audio: ^1.0.0+1

# Plugins for rendering the <svg> tag.
flutter_svg: ^0.17.4
flutter_svg: ^0.19.0

flutter:
sdk: flutter
Expand Down