forked from Sub6Resources/flutter_html
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Style to new file and prep for css parsing. Update README.md
- Loading branch information
1 parent
ece0fca
commit 7bbd22f
Showing
11 changed files
with
99 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_html/block_element.dart'; | ||
|
||
class Style { | ||
TextStyle textStyle; | ||
bool preserveWhitespace; | ||
int baselineOffset; | ||
String before; | ||
String after; | ||
TextDirection textDirection; | ||
Block block; | ||
|
||
Style({ | ||
this.textStyle, | ||
this.preserveWhitespace, | ||
this.baselineOffset, | ||
this.before, | ||
this.after, | ||
this.textDirection, | ||
this.block, | ||
}); | ||
|
||
@override | ||
String toString() { | ||
return "(Text Style: ($textStyle}),)"; | ||
} | ||
|
||
Style merge(Style other) { | ||
if (other == null) return this; | ||
|
||
TextStyle mergedTextStyle = textStyle?.merge(other.textStyle); | ||
Block mergedBlock = block?.merge(other.block); | ||
|
||
return copyWith( | ||
textStyle: mergedTextStyle, | ||
preserveWhitespace: other.preserveWhitespace, | ||
baselineOffset: other.baselineOffset, | ||
before: other.before, | ||
after: other.after, | ||
textDirection: other.textDirection, | ||
block: mergedBlock, | ||
); | ||
} | ||
|
||
Style copyWith({ | ||
TextStyle textStyle, | ||
bool preserveWhitespace, | ||
int baselineOffset, | ||
String before, | ||
String after, | ||
TextDirection textDirection, | ||
Block block, | ||
}) { | ||
return Style( | ||
textStyle: textStyle ?? this.textStyle, | ||
preserveWhitespace: preserveWhitespace ?? this.preserveWhitespace, | ||
baselineOffset: baselineOffset ?? this.baselineOffset, | ||
before: before ?? this.before, | ||
after: after ?? this.after, | ||
textDirection: textDirection ?? this.textDirection, | ||
block: block ?? this.block, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ environment: | |
|
||
dependencies: | ||
html: ^0.14.0 | ||
csslib: ^0.16.0 | ||
css_colors: ^1.0.2 | ||
flutter: | ||
sdk: flutter | ||
|
||
|