Skip to content

Commit 0b38416

Browse files
committed
Codex: Fix API drifts in README
1 parent 0d64779 commit 0b38416

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

packages/core/README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,23 @@ HtmlWidget(
6363
// render a custom widget that inlines with surrounding text
6464
return InlineCustomWidget(
6565
child: FizzBuzzWidget(),
66-
)
66+
);
6767
}
6868
6969
return null;
7070
},
7171
7272
// this callback will be triggered when user taps a link
73-
onTapUrl: (url) => print('tapped $url'),
73+
// return true to indicate the tap has been handled
74+
onTapUrl: (url) {
75+
debugPrint('tapped $url');
76+
return true;
77+
},
78+
79+
// this callback will be triggered when user taps an image
80+
onTapImage: (image) {
81+
debugPrint('image tapped: \'${image.sources.first.url}\'');
82+
},
7483
7584
// select the render mode for HTML body
7685
// by default, a simple `Column` is rendered
@@ -82,6 +91,13 @@ HtmlWidget(
8291
),
8392
```
8493

94+
## Callbacks
95+
96+
- onTapUrl: return `true` to indicate the URL tap was handled; when not handled and the URL is an in-page anchor (e.g. `#id` or `${baseUrl}#id`), it scrolls to the anchor automatically.
97+
- onTapImage: receives `ImageMetadata`; access the first source via `image.sources.first.url`.
98+
- onLoadingBuilder: shown while the widget/image is loading; receives `loadingProgress` (0.0–1.0 or null).
99+
- onErrorBuilder: shown when a complex element fails to render; receives the thrown `error`.
100+
85101
## Features
86102

87103
### HTML tags
@@ -192,6 +208,6 @@ The [enhanced](https://pub.dev/packages/flutter_widget_from_html) package uses a
192208
- [fwfh_url_launcher](https://pub.dev/packages/fwfh_url_launcher) to launch URLs
193209
- [fwfh_webview](https://pub.dev/packages/fwfh_webview) for IFRAME support
194210

195-
See [the extensibility document](https://github.com/daohoangson/flutter_widget_from_html/blob/v0.14.2/docs/extensibility.md) for detailed information.
211+
See [the extensibility document](https://github.com/daohoangson/flutter_widget_from_html/blob/master/docs/extensibility.md) for detailed information.
196212

197213
<a href="https://www.buymeacoffee.com/daohoangson" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>

packages/enhanced/README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,23 @@ HtmlWidget(
8484
// render a custom widget inline with surrounding text
8585
return InlineCustomWidget(
8686
child: FizzBuzzWidget(),
87-
)
87+
);
8888
}
8989

9090
return null;
9191
},
9292

9393
// this callback will be triggered when user taps a link
94-
onTapUrl: (url) => print('tapped $url'),
94+
// return true to indicate the tap has been handled
95+
onTapUrl: (url) {
96+
debugPrint('tapped $url');
97+
return true;
98+
},
99+
100+
// this callback will be triggered when user taps an image
101+
onTapImage: (image) {
102+
debugPrint('image tapped: \'${image.sources.first.url}\'');
103+
},
95104

96105
// select the render mode for HTML body
97106
// by default, a simple `Column` is rendered
@@ -103,6 +112,13 @@ HtmlWidget(
103112
),
104113
```
105114

115+
## Callbacks
116+
117+
- onTapUrl: return `true` to indicate the URL tap was handled; when not handled and the URL is an in-page anchor (e.g. `#id` or `${baseUrl}#id`), it scrolls to the anchor automatically.
118+
- onTapImage: receives `ImageMetadata`; access the first source via `image.sources.first.url`.
119+
- onLoadingBuilder: shown while the widget/image is loading; receives `loadingProgress` (0.0–1.0 or null).
120+
- onErrorBuilder: shown when a complex element fails to render; receives the thrown `error`.
121+
106122
## Features
107123

108124
### HTML tags
@@ -203,6 +219,6 @@ These tags and their contents will be ignored:
203219

204220
The [core](https://pub.dev/packages/flutter_widget_from_html_core) package implements widget building logic with high testing coverage to ensure correctness. It tries to render an optimal tree by using `RichText` with specific `TextStyle`, merging text spans together, showing images in sized box, etc. The idea is to build a solid foundation for apps to customize.
205221

206-
See [the extensibility document](https://github.com/daohoangson/flutter_widget_from_html/blob/v0.14.2/docs/extensibility.md) for detailed information.
222+
See [the extensibility document](https://github.com/daohoangson/flutter_widget_from_html/blob/master/docs/extensibility.md) for detailed information.
207223

208224
<a href="https://www.buymeacoffee.com/daohoangson" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>

0 commit comments

Comments
 (0)