Skip to content

Add null check #2

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"flutter": "3.32.6"
}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,7 @@ packages/**/pubspec_overrides.yaml
./pubspec_overrides.yaml
/example/pubspec_overrides.yaml

coverage/
coverage/

# FVM Version Cache
.fvm/
32 changes: 32 additions & 0 deletions example/ios/Flutter/ephemeral/flutter_lldb_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Generated file, do not edit.
#

import lldb

def handle_new_rx_page(frame: lldb.SBFrame, bp_loc, extra_args, intern_dict):
"""Intercept NOTIFY_DEBUGGER_ABOUT_RX_PAGES and touch the pages."""
base = frame.register["x0"].GetValueAsAddress()
page_len = frame.register["x1"].GetValueAsUnsigned()

# Note: NOTIFY_DEBUGGER_ABOUT_RX_PAGES will check contents of the
# first page to see if handled it correctly. This makes diagnosing
# misconfiguration (e.g. missing breakpoint) easier.
data = bytearray(page_len)
data[0:8] = b'IHELPED!'

error = lldb.SBError()
frame.GetThread().GetProcess().WriteMemory(base, data, error)
if not error.Success():
print(f'Failed to write into {base}[+{page_len}]', error)
return

def __lldb_init_module(debugger: lldb.SBDebugger, _):
target = debugger.GetDummyTarget()
# Caveat: must use BreakpointCreateByRegEx here and not
# BreakpointCreateByName. For some reasons callback function does not
# get carried over from dummy target for the later.
bp = target.BreakpointCreateByRegex("^NOTIFY_DEBUGGER_ABOUT_RX_PAGES$")
bp.SetScriptCallbackFunction('{}.handle_new_rx_page'.format(__name__))
bp.SetAutoContinue(True)
print("-- LLDB integration loaded --")
5 changes: 5 additions & 0 deletions example/ios/Flutter/ephemeral/flutter_lldbinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# Generated file, do not edit.
#

command script import --relative-to-command-file flutter_lldb_helper.py
2 changes: 0 additions & 2 deletions example/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import FlutterMacOS
import Foundation

import wakelock_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
WakelockMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockMacosPlugin"))
}
9 changes: 3 additions & 6 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ publish_to: none
version: 1.0.0+1

environment:
sdk: '>=2.17.0 <3.0.0'
sdk: ">=2.17.0 <3.0.0"

dependencies:
flutter_html:
path: ..
flutter_html_all:
path: ../packages/flutter_html_all
path: ../
flutter:
sdk: flutter

Expand All @@ -20,9 +18,8 @@ dev_dependencies:
flutter_lints: ^2.0.1

flutter:

uses-material-design: true

assets:
- assets/html5.png
- assets/mac.svg
- assets/mac.svg
5 changes: 2 additions & 3 deletions lib/src/style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,9 @@ extension _MarginRelativeValues on Margin {
Margin? getRelativeValue(double remValue, double emValue) {
double? calculatedValue = calculateRelativeValue(remValue, emValue);
if (calculatedValue != null) {
return Margin(calculatedValue);
return Margin(calculatedValue);
}

return null;
}
}
Expand All @@ -575,7 +575,6 @@ extension _PaddingRelativeValues on HtmlPadding {
if (calculatedValue != null) {
return HtmlPadding(calculatedValue);
}

return null;
}
}
Expand Down
24 changes: 16 additions & 8 deletions packages/flutter_html_all/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: flutter_html_all
description: All optional flutter_html widgets, bundled into a single package.
version: 3.0.0-beta.2
homepage: https://github.com/Sub6Resources/flutter_html
publish_to: none # Remove this line if you wish to publish to pub.dev

environment:
sdk: ">=2.12.0 <4.0.0"
Expand All @@ -10,14 +11,21 @@ environment:
dependencies:
flutter:
sdk: flutter
html: '>=0.15.0 <1.0.0'
flutter_html: ^3.0.0-beta.2
flutter_html_audio: ^3.0.0-beta.2
flutter_html_iframe: ^3.0.0-beta.2
flutter_html_math: ^3.0.0-beta.2
flutter_html_svg: ^3.0.0-beta.2
flutter_html_table: ^3.0.0-beta.2
flutter_html_video: ^3.0.0-beta.2
html: ">=0.15.0 <1.0.0"
flutter_html:
path: ../..
flutter_html_audio:
path: ../flutter_html_audio
flutter_html_iframe:
path: ../flutter_html_iframe
flutter_html_math:
path: ../flutter_html_math
flutter_html_svg:
path: ../flutter_html_svg
flutter_html_table:
path: ../flutter_html_table
flutter_html_video:
path: ../flutter_html_video

dev_dependencies:
flutter_test:
Expand Down
8 changes: 5 additions & 3 deletions packages/flutter_html_audio/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: flutter_html_audio
description: This extension package allows the <audio> tag to be rendered using the flutter_html package
version: 3.0.0-beta.2
homepage: https://github.com/Sub6Resources/flutter_html
publish_to: none # Remove this line if you wish to publish to pub.dev

environment:
sdk: ">=2.12.0 <4.0.0"
Expand All @@ -10,9 +11,10 @@ environment:
dependencies:
flutter:
sdk: flutter
html: '>=0.15.0 <1.0.0'
flutter_html: ^3.0.0-beta.2
video_player: '>=2.2.8 <3.0.0'
html: ">=0.15.0 <1.0.0"
flutter_html:
path: ../..
video_player: ">=2.2.8 <3.0.0"
chewie_audio: ^1.5.0

dev_dependencies:
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_html_iframe/lib/flutter_html_iframe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:webview_flutter/webview_flutter.dart';

import 'iframe_unsupported.dart'
if (dart.library.io) 'iframe_mobile.dart'
if (dart.library.html) 'iframe_web.dart';
if (dart.library.js_interop) 'iframe_web.dart';

class IframeHtmlExtension extends HtmlExtension {
final NavigationDelegate? navigationDelegate;
Expand Down
13 changes: 13 additions & 0 deletions packages/flutter_html_iframe/lib/iframe_mobile.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:convert';

import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -34,6 +36,17 @@ class IframeWidget extends StatelessWidget {
final givenHeight =
double.tryParse(extensionContext.attributes['height'] ?? "");

Uri? srcUri;
if (extensionContext.attributes['srcdoc'] != null) {
srcUri = Uri.dataFromString(
extensionContext.attributes['srcdoc'] ?? '',
mimeType: 'text/html',
encoding: Encoding.getByName('utf-8'),
);
} else {
srcUri = Uri.tryParse(extensionContext.attributes['src'] ?? "") ?? Uri();
}

return SizedBox(
width: givenWidth ?? (givenHeight ?? 150) * 2,
height: givenHeight ?? (givenWidth ?? 300) / 2,
Expand Down
10 changes: 5 additions & 5 deletions packages/flutter_html_iframe/lib/iframe_web.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'dart:convert';
import 'dart:math';
import 'package:web/web.dart' as web;
import 'dart:ui_web' as ui_web;

import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_html_iframe/shims/dart_ui.dart' as ui;
// ignore: avoid_web_libraries_in_flutter
import 'dart:html' as html;

import 'package:webview_flutter/webview_flutter.dart';

Expand All @@ -25,13 +25,13 @@ class IframeWidget extends StatelessWidget {
double.tryParse(extensionContext.attributes['width'] ?? "");
final givenHeight =
double.tryParse(extensionContext.attributes['height'] ?? "");
final html.IFrameElement iframe = html.IFrameElement()
final web.HTMLIFrameElement iframe = web.HTMLIFrameElement()
..width = (givenWidth ?? (givenHeight ?? 150) * 2).toString()
..height = (givenHeight ?? (givenWidth ?? 300) / 2).toString()
..src = extensionContext.attributes['src']
..src = extensionContext.attributes['src'] ?? ''
..style.border = 'none';
final String createdViewId = _getRandString(10);
ui.platformViewRegistry
ui_web.platformViewRegistry
.registerViewFactory(createdViewId, (int viewId) => iframe);
return SizedBox(
width: double.tryParse(extensionContext.attributes['width'] ?? "") ??
Expand Down
10 changes: 0 additions & 10 deletions packages/flutter_html_iframe/lib/shims/dart_ui.dart

This file was deleted.

19 changes: 0 additions & 19 deletions packages/flutter_html_iframe/lib/shims/dart_ui_fake.dart

This file was deleted.

5 changes: 0 additions & 5 deletions packages/flutter_html_iframe/lib/shims/dart_ui_real.dart

This file was deleted.

10 changes: 6 additions & 4 deletions packages/flutter_html_iframe/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: flutter_html_iframe
description: This extension package allows the <iframe> tag to be rendered using the flutter_html package
version: 3.0.0-beta.2
homepage: https://github.com/Sub6Resources/flutter_html
publish_to: none # Remove this line if you wish to publish to pub.dev

environment:
sdk: ">=2.12.0 <4.0.0"
Expand All @@ -10,9 +11,10 @@ environment:
dependencies:
flutter:
sdk: flutter
html: '>=0.15.0 <1.0.0'
flutter_html: ^3.0.0-beta.2
webview_flutter: '>=4.0.0 <5.0.0'
flutter_html:
path: ../..
web: ^1.1.1
webview_flutter: ">=4.0.0 <5.0.0"

dev_dependencies:
flutter_test:
Expand All @@ -27,4 +29,4 @@ topics:
- css
- iframe
- layout
- flutter_html
- web
8 changes: 5 additions & 3 deletions packages/flutter_html_math/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: flutter_html_math
description: This extension package allows the <math> tag to be rendered using the flutter_html package
version: 3.0.0-beta.2
homepage: https://github.com/Sub6Resources/flutter_html
publish_to: none # Remove this line if you wish to publish to pub.dev

environment:
sdk: ">=2.12.0 <4.0.0"
Expand All @@ -10,9 +11,10 @@ environment:
dependencies:
flutter:
sdk: flutter
html: '>=0.15.0 <1.0.0'
flutter_html: ^3.0.0-beta.2
flutter_math_fork: '>=0.6.0 <1.0.0'
html: ">=0.15.0 <1.0.0"
flutter_html:
path: ../..
flutter_math_fork: ">=0.6.0 <1.0.0"

dev_dependencies:
flutter_test:
Expand Down
8 changes: 5 additions & 3 deletions packages/flutter_html_svg/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: flutter_html_svg
description: This extension package allows the <svg> tag and svg-based img sources to be rendered using the flutter_html package
version: 3.0.0-beta.2
homepage: https://github.com/Sub6Resources/flutter_html
publish_to: none # Remove this line if you wish to publish to pub.dev

environment:
sdk: ">=2.17.0 <4.0.0"
Expand All @@ -10,9 +11,10 @@ environment:
dependencies:
flutter:
sdk: flutter
html: '>=0.15.0 <1.0.0'
flutter_html: ^3.0.0-beta.2
flutter_svg: '>=1.0.0 <3.0.0'
html: ">=0.15.0 <1.0.0"
flutter_html:
path: ../..
flutter_svg: ">=1.0.0 <3.0.0"

dev_dependencies:
flutter_test:
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_html_svg/test/test_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const svgString = '''
</svg>
''';
final String svgEncoded = Uri.encodeFull(svgString);
final svgBase64 = base64Encode(utf8.encode(svgString) as Uint8List);
final svgBase64 = base64Encode(utf8.encode(svgString));

class FakeAssetBundle extends Fake implements AssetBundle {
@override
Expand Down
8 changes: 5 additions & 3 deletions packages/flutter_html_table/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ description: This extension package allows the <table> tag to be rendered using

version: 3.0.0-beta.2
homepage: https://github.com/Sub6Resources/flutter_html
publish_to: none # Remove this line if you wish to publish to pub.dev

environment:
sdk: ">=2.17.0 <4.0.0"
Expand All @@ -11,9 +12,10 @@ environment:
dependencies:
flutter:
sdk: flutter
html: '>=0.15.0 <1.0.0'
flutter_html: ^3.0.0-beta.2
flutter_layout_grid: '>=1.0.1 <3.0.0'
html: ">=0.15.0 <1.0.0"
flutter_html:
path: ../..
flutter_layout_grid: ">=1.0.1 <3.0.0"

dev_dependencies:
flutter_test:
Expand Down
10 changes: 6 additions & 4 deletions packages/flutter_html_video/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: flutter_html_video
description: This extension package allows the <video> tag to be rendered using the flutter_html package
version: 3.0.0-beta.2
homepage: https://github.com/Sub6Resources/flutter_html
publish_to: none # Remove this line if you wish to publish to pub.dev

environment:
sdk: ">=2.12.0 <4.0.0"
Expand All @@ -10,10 +11,11 @@ environment:
dependencies:
flutter:
sdk: flutter
html: '>=0.15.0 <1.0.0'
flutter_html: ^3.0.0-beta.2
video_player: '>=2.2.8 <3.0.0'
chewie: '>=1.1.0 <2.0.0'
html: ">=0.15.0 <1.0.0"
flutter_html:
path: ../..
video_player: ">=2.2.8 <3.0.0"
chewie: ">=1.1.0 <2.0.0"

dev_dependencies:
flutter_test:
Expand Down