Skip to content

Handled relative path in image URLs: #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d560278
Handled relative path in image urls:
Aug 23, 2019
2039240
Implement li leading char as TextSpan rather than separate widget
amake Jul 19, 2019
4ee8640
Add shrinkToFit option to shrink Html to its natural content width
amake Jul 19, 2019
ac97ee9
Update test image URL
amake Jul 19, 2019
431a08f
Organize imports
amake Jul 19, 2019
a671d94
Create CONTRIBUTING.md
Sub6Resources Sep 6, 2019
c5278bb
change parse to tryParse in image width. Fixes #118
Sub6Resources Sep 6, 2019
247a8f3
Allow negative numbers to fix #97
Sub6Resources Sep 6, 2019
f1fe495
Fix image alt attribute (fixes #96)
Sub6Resources Sep 9, 2019
f38b56f
Add partial support for sub and remove unused functions
Sub6Resources Sep 10, 2019
059bfe0
Merge branch '0.11.0' into shrink-to-fit
Sub6Resources Sep 10, 2019
52c8927
Merge pull request #148 from amake/shrink-to-fit
Sub6Resources Sep 10, 2019
18950af
Update readme for latest merged pr to show that it fixes #75
Sub6Resources Sep 10, 2019
2e4d2ab
Prepare for release
Sub6Resources Sep 10, 2019
a7aa1fd
Merge pull request #152 from Sub6Resources/0.11.0
Sub6Resources Sep 10, 2019
846ae21
Add golden tests for all supported html elements
Sub6Resources Sep 10, 2019
c28db9f
Add check for flutter version in tests
Sub6Resources Sep 10, 2019
b8644ec
Add screenshot to readme
Sub6Resources Sep 10, 2019
d55aa45
Add check for null onLinkTap callback
Sub6Resources Sep 11, 2019
9892279
Try to fix golden tests
Sub6Resources Sep 13, 2019
213efa0
Check that files are loaded correctly in circleci
Sub6Resources Sep 13, 2019
6854229
Update golden files
Sub6Resources Sep 16, 2019
573705e
- Refactored prefixNetworkImageRelativePath -> prefixImagePath
Sep 18, 2019
fe51711
Handled relative path in image urls:
Aug 23, 2019
2d0bb5e
- Refactored prefixNetworkImageRelativePath -> prefixImagePath
Sep 18, 2019
5ea2907
Merge branch 'master' of https://github.com/arnold-parge/flutter_html
Sep 18, 2019
b0df4a3
fixed space in imageUrl
Sep 18, 2019
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 .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ jobs:
- image: cirrusci/flutter
steps:
- checkout
- run: flutter --version
- run: flutter test
Binary file added .github/flutter_html_screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## [0.11.0] - September 10, 2019:

* Make it so `width=100%` doesn't throw error. Fixes [#118](https://github.com/Sub6Resources/flutter_html/issues/118).
* You can now set width and/or height in `ImageProperties` to negative to ignore the `width` and/or `height` values from the html. Fixes [#97](https://github.com/Sub6Resources/flutter_html/issues/97)
* The `img` `alt` property now renders correctly when the image fails to load and with the correct style. Fixes [#96](https://github.com/Sub6Resources/flutter_html/issues/96)
* Add partial support for `sub` tag.
* Add new option: `shrinkToFit` ([#148](https://github.com/Sub6Resources/flutter_html/pull/148)). Fixes [#75](https://github.com/Sub6Resources/flutter_html/issues/75).

## [0.10.4] - June 22, 2019:

* Add support for `customTextStyle` to block and specialty HTML elements.
Expand Down
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Thanks for your interest in contributing to `flutter_html`!

I'm pretty busy, so in order to help me best make use of the time I spend working on this project, please adhere to the following guidelines when contributing:

1. In general, don't submit a pull request without discussing the feature with me, in an issue, first. I don't want you to have to do a whole bunch of work for nothing. This also makes it so there won't be a whole bunch of changes I make you do in order to have your pull request merged.
2. Please read the [wiki](https://github.com/Sub6Resources/flutter_html/wiki) before contributing (there are only two pages at the moment). This will give you an idea of what my plans are for this repository, and what you do and don't need to work on.

More specific guidelines will be added soon.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@

A Flutter widget for rendering static html tags as Flutter widgets. (Will render over 70 different html tags!)

## Roadmap
[View the development roadmap in the wiki](https://github.com/Sub6Resources/flutter_html/wiki/Roadmap)
<img alt="A Screenshot of flutter_html" src=".github/flutter_html_screenshot.png" width="300"/>

## Installing:

Add the following to your `pubspec.yaml` file:

dependencies:
flutter_html: ^0.10.4
flutter_html: ^0.11.0

## Currently Supported HTML Tags:
`a`, `abbr`, `acronym`, `address`, `article`, `aside`, `b`, `bdi`, `bdo`, `big`, `blockquote`, `body`, `br`, `caption`, `cite`, `code`, `data`, `dd`, `del`, `dfn`, `div`, `dl`, `dt`, `em`, `figcaption`, `figure`, `footer`, `h1`, `h2`, `h3`, `h4`, `h5`, `h6`, `header`, `hr`, `i`, `img`, `ins`, `kbd`, `li`, `main`, `mark`, `nav`, `noscript`, `ol`, `p`, `pre`, `q`, `rp`, `rt`, `ruby`, `s`, `samp`, `section`, `small`, `span`, `strike`, `strong`, `sub`, `sup`, `table`, `tbody`, `td`, `template`, `tfoot`, `th`, `thead`, `time`, `tr`, `tt`, `u`, `ul`, `var`

## Roadmap
[View the development roadmap in the wiki](https://github.com/Sub6Resources/flutter_html/wiki/Roadmap)

### Partially supported elements:
> These are common elements that aren't yet fully supported, but won't be ignored and will still render somewhat correctly.

Expand Down
2 changes: 1 addition & 1 deletion example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class _MyHomePageState extends State<MyHomePage> {
<br />
Second nested div<br />
<figure>
<img src="https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png" />
<img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" />
<figcaption>Available on GitHub</figcaption>
</figure>
</div>
Expand Down
7 changes: 5 additions & 2 deletions lib/flutter_html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ library flutter_html;
import 'package:flutter/material.dart';
import 'package:flutter_html/html_parser.dart';
import 'package:flutter_html/rich_text_parser.dart';

import 'image_properties.dart';

class Html extends StatelessWidget {
Expand All @@ -25,6 +26,7 @@ class Html extends StatelessWidget {
decoration: TextDecoration.underline,
color: Colors.blueAccent,
decorationColor: Colors.blueAccent),
this.shrinkToFit = false,
this.imageProperties,
this.onImageTap,
this.showImages = true,
Expand All @@ -40,6 +42,7 @@ class Html extends StatelessWidget {
final bool useRichText;
final ImageErrorListener onImageError;
final TextStyle linkStyle;
final bool shrinkToFit;

/// Properties for the Image widget that gets rendered by the rich text parser
final ImageProperties imageProperties;
Expand All @@ -55,7 +58,7 @@ class Html extends StatelessWidget {

@override
Widget build(BuildContext context) {
final double width = MediaQuery.of(context).size.width;
final double width = shrinkToFit ? null : MediaQuery.of(context).size.width;

return Container(
padding: padding,
Expand All @@ -65,7 +68,7 @@ class Html extends StatelessWidget {
style: defaultTextStyle ?? DefaultTextStyle.of(context).style,
child: (useRichText)
? HtmlRichTextParser(
width: width,
shrinkToFit: shrinkToFit,
onLinkTap: onLinkTap,
renderNewlines: renderNewlines,
customEdgeInsets: customEdgeInsets,
Expand Down
4 changes: 1 addition & 3 deletions lib/html_parser.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import 'dart:convert';
import 'package:flutter_html/rich_text_parser.dart';

import 'image_properties.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/rich_text_parser.dart';
import 'package:html/dom.dart' as dom;
import 'package:html/parser.dart' as parser;

Expand Down
2 changes: 2 additions & 0 deletions lib/image_properties.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ImageProperties {
final bool matchTextDirection;
final FilterQuality filterQuality;
final double scale;
final String prefixImagePath;

const ImageProperties({
this.scale = 1,
Expand All @@ -30,5 +31,6 @@ class ImageProperties {
this.centerSlice,
this.matchTextDirection = false,
this.filterQuality = FilterQuality.low,
this.prefixImagePath = ''
});
}
Loading