Skip to content
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

Fix error #4

Open
wants to merge 6 commits into
base: main
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
95 changes: 64 additions & 31 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,49 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety.3"
version: "2.8.2"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
version: "2.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.5"
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.3"
version: "1.3.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.5"
version: "1.16.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.0.5"
draft_view:
dependency: "direct main"
description:
Expand All @@ -63,7 +63,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.3"
version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -74,34 +74,53 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.4"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety.3"
version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.6"
version: "1.7.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.3"
version: "1.8.1"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
version: "2.1.2"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -113,91 +132,105 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.4"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.6"
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.3"
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19-nullsafety.6"
typed_data:
version: "0.4.9"
url_launcher:
dependency: transitive
description:
name: typed_data
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.5"
url_launcher:
version: "6.1.4"
url_launcher_android:
dependency: transitive
description:
name: url_launcher
name: url_launcher_android
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.17"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.0-nullsafety.4"
version: "6.0.17"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0-nullsafety.3"
version: "3.0.1"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0-nullsafety.2"
version: "3.0.1"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0-nullsafety.1"
version: "2.1.0"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.12"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0-nullsafety.2"
version: "3.0.1"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.5"
version: "2.1.2"
sdks:
dart: ">=2.12.0-0.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.10.0"
17 changes: 13 additions & 4 deletions lib/draft_view/block/base_block.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class BaseBlock {
);

/// If the range within the current block's range
bool withinRange(int start, int end) {
bool withInRange(int start, int end) {
if (start == end) {
return false;
}
Expand Down Expand Up @@ -281,9 +281,18 @@ class BaseBlock {
: FontStyle.normal;

/// Get decoration for each block based on their [inline styles]
TextDecoration get decoration => this.inlineStyles.contains("UNDERLINE")
? TextDecoration.underline
: TextDecoration.none;
TextDecoration get decoration {
TextDecoration decoration = TextDecoration.none;
if (inlineStyles.contains("UNDERLINE")) {
decoration =
TextDecoration.combine([decoration, TextDecoration.underline]);
}
if (inlineStyles.contains("STRIKETHROUGH")) {
decoration =
TextDecoration.combine([decoration, TextDecoration.lineThrough]);
}
return decoration;
}

/// Render style based on the block's type and inline styles
TextStyle renderStyle(BuildContext context) {
Expand Down
11 changes: 5 additions & 6 deletions lib/draft_view/block/blocks/audio_block.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:draft_view/draft_view/block/base_block.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:url_launcher/url_launcher_string.dart';

extension on Duration {
String toAudioString() {
Expand All @@ -14,8 +13,8 @@ extension on Duration {
return "-${-this}";
}
String twoDigitHours = twoDigits(inHours);
String twoDigitMinutes = twoDigits(inMinutes.remainder(60) as int);
String twoDigitSeconds = twoDigits(inSeconds.remainder(60) as int);
String twoDigitMinutes = twoDigits(inMinutes.remainder(60));
String twoDigitSeconds = twoDigits(inSeconds.remainder(60));

return "$twoDigitHours:$twoDigitMinutes:$twoDigitSeconds";
}
Expand Down Expand Up @@ -175,8 +174,8 @@ class _AudioComponentState extends State<AudioComponent> {
WidgetSpan(
child: InkWell(
onTap: () async {
if (await canLaunch(widget.url)) {
await launch(widget.url);
if (await canLaunchUrlString(widget.url)) {
await launchUrlString(widget.url);
}
},
child: Text(
Expand Down
7 changes: 4 additions & 3 deletions lib/draft_view/block/blocks/header_block.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:convert';
import 'package:draft_view/draft_view/block/base_block.dart';
import 'package:flutter/material.dart';

Expand Down Expand Up @@ -29,7 +30,7 @@ class HeaderBlock extends BaseBlock {
);

HeaderBlock copyWith({BaseBlock? block}) => HeaderBlock(
depth: block?.depth ?? depth,
depth: block?.depth ?? this.depth,
start: block?.start ?? this.start,
end: block?.end ?? this.end,
inlineStyles: block?.inlineStyles ?? this.inlineStyles,
Expand All @@ -38,7 +39,7 @@ class HeaderBlock extends BaseBlock {
text: block?.text ?? this.text,
blockType: block?.blockType ?? this.blockType,
level: this.level,
children: block?.children ?? children ?? [],
children: block?.children ?? this.children ?? [],
);

@override
Expand Down Expand Up @@ -102,6 +103,6 @@ class HeaderBlock extends BaseBlock {

@override
InlineSpan render(BuildContext context, {List<InlineSpan>? children}) {
return TextSpan(text: "$textContent", style: renderStyle(context));
return TextSpan(text: textContent, style: renderStyle(context));
}
}
4 changes: 2 additions & 2 deletions lib/draft_view/block/blocks/image_block.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class _ImageComponentState extends State<ImageComponent> {
),
),
Hero(
tag: Key("${widget.caption}"),
tag: Key("${widget.url}"),
child: Text("${widget.caption}"),
),
],
Expand Down Expand Up @@ -165,7 +165,7 @@ class _ImageDetailViewState extends State<ImageDetailView> {
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Hero(
tag: Key("${widget.caption}"),
tag: Key("${widget.url}"),
child: Text(
"${widget.caption ?? ""}",
style: TextStyle(color: Colors.white, fontSize: 20),
Expand Down
Loading