Skip to content

Commit 231a584

Browse files
committed
[flutter_html_iframe] Fix compile error in Flutter 3.32.0
- correct conditional imports: use dart.library.js_interop instead of dart.library.html - remove ui_fake classes, it is legacy implementation and should be replaced by web_ui package This was kinda fixed in a PR Sub6Resources#1485
1 parent e0e72b6 commit 231a584

File tree

14 files changed

+59
-60
lines changed

14 files changed

+59
-60
lines changed

.fvmrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"flutter": "3.32.6"
3+
}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,7 @@ packages/**/pubspec_overrides.yaml
156156
./pubspec_overrides.yaml
157157
/example/pubspec_overrides.yaml
158158

159-
coverage/
159+
coverage/
160+
161+
# FVM Version Cache
162+
.fvm/
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
# Generated file, do not edit.
3+
#
4+
5+
import lldb
6+
7+
def handle_new_rx_page(frame: lldb.SBFrame, bp_loc, extra_args, intern_dict):
8+
"""Intercept NOTIFY_DEBUGGER_ABOUT_RX_PAGES and touch the pages."""
9+
base = frame.register["x0"].GetValueAsAddress()
10+
page_len = frame.register["x1"].GetValueAsUnsigned()
11+
12+
# Note: NOTIFY_DEBUGGER_ABOUT_RX_PAGES will check contents of the
13+
# first page to see if handled it correctly. This makes diagnosing
14+
# misconfiguration (e.g. missing breakpoint) easier.
15+
data = bytearray(page_len)
16+
data[0:8] = b'IHELPED!'
17+
18+
error = lldb.SBError()
19+
frame.GetThread().GetProcess().WriteMemory(base, data, error)
20+
if not error.Success():
21+
print(f'Failed to write into {base}[+{page_len}]', error)
22+
return
23+
24+
def __lldb_init_module(debugger: lldb.SBDebugger, _):
25+
target = debugger.GetDummyTarget()
26+
# Caveat: must use BreakpointCreateByRegEx here and not
27+
# BreakpointCreateByName. For some reasons callback function does not
28+
# get carried over from dummy target for the later.
29+
bp = target.BreakpointCreateByRegex("^NOTIFY_DEBUGGER_ABOUT_RX_PAGES$")
30+
bp.SetScriptCallbackFunction('{}.handle_new_rx_page'.format(__name__))
31+
bp.SetAutoContinue(True)
32+
print("-- LLDB integration loaded --")
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#
2+
# Generated file, do not edit.
3+
#
4+
5+
command script import --relative-to-command-file flutter_lldb_helper.py

example/macos/Flutter/GeneratedPluginRegistrant.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import FlutterMacOS
66
import Foundation
77

8-
import wakelock_macos
98

109
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
11-
WakelockMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockMacosPlugin"))
1210
}

lib/src/css_parser.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -671,10 +671,8 @@ Style? inlineCssToStyle(String? inlineStyle, OnCssParseError? errorHandler) {
671671
return declarationsToStyle(declarations["*"]!);
672672
} else if (errorHandler != null) {
673673
String? newCss = errorHandler.call(inlineStyle ?? "", errors);
674-
if (newCss != null) {
675-
return inlineCssToStyle(newCss, errorHandler);
674+
return inlineCssToStyle(newCss, errorHandler);
676675
}
677-
}
678676
return null;
679677
}
680678

@@ -689,10 +687,8 @@ Map<String, Map<String, List<css.Expression>>> parseExternalCss(
689687
return DeclarationVisitor().getDeclarations(sheet);
690688
} else if (errorHandler != null) {
691689
String? newCss = errorHandler.call(css, errors);
692-
if (newCss != null) {
693-
return parseExternalCss(newCss, errorHandler);
690+
return parseExternalCss(newCss, errorHandler);
694691
}
695-
}
696692
return {};
697693
}
698694

lib/src/style.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -561,21 +561,17 @@ class Style {
561561
extension _MarginRelativeValues on Margin {
562562
Margin? getRelativeValue(double remValue, double emValue) {
563563
double? calculatedValue = calculateRelativeValue(remValue, emValue);
564-
if (calculatedValue != null) {
565-
return Margin(calculatedValue);
566-
}
567-
564+
return Margin(calculatedValue);
565+
568566
return null;
569567
}
570568
}
571569

572570
extension _PaddingRelativeValues on HtmlPadding {
573571
HtmlPadding? getRelativeValue(double remValue, double emValue) {
574572
double? calculatedValue = calculateRelativeValue(remValue, emValue);
575-
if (calculatedValue != null) {
576-
return HtmlPadding(calculatedValue);
577-
}
578-
573+
return HtmlPadding(calculatedValue);
574+
579575
return null;
580576
}
581577
}

packages/flutter_html_iframe/lib/flutter_html_iframe.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:webview_flutter/webview_flutter.dart';
66

77
import 'iframe_unsupported.dart'
88
if (dart.library.io) 'iframe_mobile.dart'
9-
if (dart.library.html) 'iframe_web.dart';
9+
if (dart.library.js_interop) 'iframe_web.dart';
1010

1111
class IframeHtmlExtension extends HtmlExtension {
1212
final NavigationDelegate? navigationDelegate;

packages/flutter_html_iframe/lib/iframe_web.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import 'dart:convert';
22
import 'dart:math';
3+
import 'package:web/web.dart' as web;
4+
import 'dart:ui_web' as ui_web;
35

46
import 'package:flutter/material.dart';
57
import 'package:flutter_html/flutter_html.dart';
6-
import 'package:flutter_html_iframe/shims/dart_ui.dart' as ui;
78
// ignore: avoid_web_libraries_in_flutter
8-
import 'dart:html' as html;
99

1010
import 'package:webview_flutter/webview_flutter.dart';
1111

@@ -25,13 +25,13 @@ class IframeWidget extends StatelessWidget {
2525
double.tryParse(extensionContext.attributes['width'] ?? "");
2626
final givenHeight =
2727
double.tryParse(extensionContext.attributes['height'] ?? "");
28-
final html.IFrameElement iframe = html.IFrameElement()
28+
final web.HTMLIFrameElement iframe = web.HTMLIFrameElement()
2929
..width = (givenWidth ?? (givenHeight ?? 150) * 2).toString()
3030
..height = (givenHeight ?? (givenWidth ?? 300) / 2).toString()
31-
..src = extensionContext.attributes['src']
31+
..src = extensionContext.attributes['src'] ?? ''
3232
..style.border = 'none';
3333
final String createdViewId = _getRandString(10);
34-
ui.platformViewRegistry
34+
ui_web.platformViewRegistry
3535
.registerViewFactory(createdViewId, (int viewId) => iframe);
3636
return SizedBox(
3737
width: double.tryParse(extensionContext.attributes['width'] ?? "") ??

packages/flutter_html_iframe/lib/shims/dart_ui.dart

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)