diff --git a/packages/fwfh_webview/lib/src/internal.dart b/packages/fwfh_webview/lib/src/internal.dart
index 0c8fada47..e48c81802 100644
--- a/packages/fwfh_webview/lib/src/internal.dart
+++ b/packages/fwfh_webview/lib/src/internal.dart
@@ -1,4 +1,5 @@
const kTagIframe = 'iframe';
+const kAttributeIframeDataSrc = 'data-src';
const kAttributeIframeHeight = 'height';
const kAttributeIframeSandbox = 'sandbox';
const kAttributeIframeSandboxAllowScripts = 'allow-scripts';
diff --git a/packages/fwfh_webview/lib/src/web_view_factory.dart b/packages/fwfh_webview/lib/src/web_view_factory.dart
index 3302b54fa..f66691752 100644
--- a/packages/fwfh_webview/lib/src/web_view_factory.dart
+++ b/packages/fwfh_webview/lib/src/web_view_factory.dart
@@ -132,7 +132,11 @@ mixin WebViewFactory on WidgetFactory {
}
final a = meta.element.attributes;
- final src = urlFull(a[kAttributeIframeSrc] ?? '');
+ final dataSrc = a[kAttributeIframeDataSrc];
+ final srcAttr = a[kAttributeIframeSrc];
+ final src = urlFull(
+ (srcAttr?.isNotEmpty == true) ? srcAttr! : (dataSrc ?? '')
+ );
if (src == null) {
return widgets;
}
diff --git a/packages/fwfh_webview/test/web_view_factory_test.dart b/packages/fwfh_webview/test/web_view_factory_test.dart
index 26fba6773..4ed5d5e77 100644
--- a/packages/fwfh_webview/test/web_view_factory_test.dart
+++ b/packages/fwfh_webview/test/web_view_factory_test.dart
@@ -318,6 +318,32 @@ void main() {
});
});
+ group('data-src attribute', () {
+ testWidgets('renders with data-src', (tester) async {
+ const html = '';
+ final explained = await explain(tester, html);
+ expect(explained, contains('url=$src,'));
+ });
+
+ testWidgets('src takes priority over data-src', (tester) async {
+ const html = '';
+ final explained = await explain(tester, html);
+ expect(explained, contains('url=$src/2,'));
+ });
+
+ testWidgets('falls back to data-src when src is empty', (tester) async {
+ const html = '';
+ final explained = await explain(tester, html);
+ expect(explained, contains('url=$src,'));
+ });
+
+ testWidgets('uses src when data-src is missing', (tester) async {
+ const html = '';
+ final explained = await explain(tester, html);
+ expect(explained, contains('url=$src,'));
+ });
+ });
+
group('errors', () {
testWidgets('no src', (tester) async {
const html = '';
@@ -330,6 +356,12 @@ void main() {
final explained = await explain(tester, html);
expect(explained, equals('[widget0]'));
});
+
+ testWidgets('bad data-src (cannot build full url)', (tester) async {
+ const html = '';
+ final explained = await explain(tester, html);
+ expect(explained, equals('[widget0]'));
+ });
});
}