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

feat: upgrade to Flutter 3.27.0 #1020

Merged
merged 3 commits into from
Jan 17, 2025
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- uses: subosito/flutter-action@v2
with:
channel: "stable"
flutter-version: "3.22.0"
flutter-version: "3.27.0"
cache: true

- name: Run tests
Expand Down
59 changes: 59 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,62 @@
## 5.0.0

- fix: export pdf set font not work by @Linij in https://github.com/AppFlowy-IO/appflowy-editor/pull/923
- fix: \_deleteBackward deleteRange start must > 0 by @Linij in https://github.com/AppFlowy-IO/appflowy-editor/pull/928
- chore: update device_info_plus to 11.0.0 by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/931
- fix: html decoder ignores h4-h6 tags by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/932
- fix: markdown parser doesn't recognize softline breaks by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/933
- feat: select multiple lines with block selection style by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/936
- feat: custom slice function by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/935
- fix: use retain instead of insert/delete for same attr by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/937
- fix: update migration guide by @emmanuel-ferdman in https://github.com/AppFlowy-IO/appflowy-editor/pull/929
- fix: replace texts assertion by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/938
- fix: links starting with 0 index lose href attribute after formating by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/947
- fix: replace texts may result in incorrect afterSelection by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/952
- fix: cancel block selection when tapping the editor on mobile by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/956
- fix: highlight search match not scrolling document to reveal said match by @richardshiue in https://github.com/AppFlowy-IO/appflowy-editor/pull/954
- fix: cursor height is inconsistent when the font size is smaller than the default text size by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/958
- feat: exclude padding when highlight heading block by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/960
- fix: move cursor up / down error by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/961
- fix: table resizing when rect not rendered by @Xazin in https://github.com/AppFlowy-IO/appflowy-editor/pull/967
- fix: Searching command with / using in18 by @Ahad-patel in https://github.com/AppFlowy-IO/appflowy-editor/pull/966
- fix: cut collapsed table cell won't crash the editor by @saif-ellafi in https://github.com/AppFlowy-IO/appflowy-editor/pull/963
- fix: deleting the last table being the last node of the document, places an empty node to avoid the editor to crash by @saif-ellafi in https://github.com/AppFlowy-IO/appflowy-editor/pull/951
- fix: cross blocks format not reflected on the float toolbar by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/971
- feat: support in memory transaction update by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/972
- fix: editor now detects phone number and launches it by @ARYPROGRAMMER in https://github.com/AppFlowy-IO/appflowy-editor/pull/970
- fix: ignore backspace on empty table cells to avoid editor crash by @saif-ellafi in https://github.com/AppFlowy-IO/appflowy-editor/pull/964
- fix: hide the floating toolbar if no content is visible by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/976
- fix: skip repeated key events when the slash menu is opening by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/978
- fix: creating document from slash menu leaves text behind by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/980
- fix: closing a ')' braket to create a link will erase a text following it to the end of a paragraph by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/983
- fix: underscore works should not be interpreted in inline-code by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/984
- feat: support customize supported node types for slash menu by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/982
- chore: refactor html test by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/987
- fix: issue #6808 of appflowy by @asjqkkkk in https://github.com/AppFlowy-IO/appflowy-editor/pull/986
- fix: cross column deletion in the table by @Linij in https://github.com/AppFlowy-IO/appflowy-editor/pull/934
- feat: add command shortcut keys to convert text to title by @Ahad-patel in https://github.com/AppFlowy-IO/appflowy-editor/pull/921
- Fixed menu closing on some devices by @g-apparence in https://github.com/AppFlowy-IO/appflowy-editor/pull/941
- feat: reset to the default inline code format logic by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/988
- feat: add `partialSliced` to support partial sliced attributes by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/989
- fix: shift+enter should wrap the line in list by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/990
- fix: assertion error in auto_expand_editor example by @mikefaust-jm in https://github.com/AppFlowy-IO/appflowy-editor/pull/991
- fix: all the text pasted from google doc will be applied inline link by @asjqkkkk in https://github.com/AppFlowy-IO/appflowy-editor/pull/993
- fix: sougou IME issue on Windows by @asjqkkkk in https://github.com/AppFlowy-IO/appflowy-editor/pull/1000
- feat: deep copy the node by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/995
- fix: checking is mounted before updating the value of PropertyValueNotifier(#977) by @asjqkkkk in https://github.com/AppFlowy-IO/appflowy-editor/pull/997
- feat: support text align in text-based blocks by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/1002
- feat: enable debug paint size for mobile drag handle by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/1007
- fix: out of text range while composing error by @kyungilcho in https://github.com/AppFlowy-IO/appflowy-editor/pull/979
- fix: error format of TextEditingDeltaInsertion by @asjqkkkk in https://github.com/AppFlowy-IO/appflowy-editor/pull/1004
- feat: clear selection extra info before inserting a new line by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/1009
- fix: enter after emoji will create a softbreak on mobile by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/1010
- feat: expose text span for text style builder by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/1011
- fix: using space bar to move the cursor not working on Android by @asjqkkkk in https://github.com/AppFlowy-IO/appflowy-editor/pull/1013
- fix: unable to parse image if the image is inside the paragraph by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/1012
- fix: use jump to when cursor not rendered by @richardshiue in https://github.com/AppFlowy-IO/appflowy-editor/pull/1015
- fix: check if scroll service is disposed before scrolling by @richardshiue in https://github.com/AppFlowy-IO/appflowy-editor/pull/1016
- feat: support copy with indentPadding by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/1018

## 4.0.0

- feat: support dragging to reorder block by @LucasXu0 in [#887](https://github.com/AppFlowy-IO/appflowy-editor/pull/887)
Expand Down
2 changes: 2 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/customize_theme_for_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class _CustomizeThemeForEditorState extends State<CustomizeThemeForEditor> {
: const EdgeInsets.symmetric(horizontal: 20),
cursorColor: Colors.green,
dragHandleColor: Colors.green,
selectionColor: Colors.green.withOpacity(0.5),
selectionColor: Colors.green.withValues(alpha: 0.5),
textStyleConfiguration: TextStyleConfiguration(
text: GoogleFonts.poppins(
fontSize: 14.0,
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class _EditorState extends State<Editor> {
child: Container(
padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 12),
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.1),
color: Colors.black.withValues(alpha: 0.1),
borderRadius: BorderRadius.only(
topLeft: const Radius.circular(8),
bottomLeft: UniversalPlatform.isMobile
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/markdown_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class _MarkdownEditorState extends State<MarkdownEditor> {
padding: const EdgeInsets.symmetric(horizontal: 16),
cursorColor: Colors.transparent,
cursorWidth: 0,
selectionColor: Colors.grey.withOpacity(0.3),
selectionColor: Colors.grey.withValues(alpha: 0.3),
textStyleConfiguration: TextStyleConfiguration(
lineHeight: 1.2,
applyHeightToFirstAscent: true,
Expand Down
6 changes: 5 additions & 1 deletion example/macos/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import Cocoa
import FlutterMacOS

@NSApplicationMain
@main
class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}

override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}
}
2 changes: 1 addition & 1 deletion lib/appflowy_editor.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// AppFlowyEditor library
library appflowy_editor;
library;

// core part, including document, node, selection, etc.
export 'src/core/core.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class _UploadImageMenuState extends State<UploadImageMenu> {
BoxShadow(
blurRadius: 5,
spreadRadius: 1,
color: Colors.black.withOpacity(0.1),
color: Colors.black.withValues(alpha: 0.1),
),
],
// borderRadius: BorderRadius.circular(6.0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class _ResizableImageState extends State<ResizableImage> {
child: Container(
height: 40,
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.5),
color: Colors.black.withValues(alpha: 0.5),
borderRadius: const BorderRadius.all(
Radius.circular(5.0),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ bool handleFormatByWrappingWithDoubleCharacter({
case DoubleCharacterFormatStyle.strikethrough:
style = 'strikethrough';
break;
default:
style = '';
assert(false, 'Invalid format style');
}

// if the text is already formatted, we should remove the format.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ bool handleFormatByWrappingWithSingleCharacter({
case FormatStyleByWrappingWithSingleChar.strikethrough:
style = 'strikethrough';
break;
default:
style = '';
assert(false, 'Invalid format style');
}

// if the text is already formatted, we should remove the format.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';

/// Option/Alt + Shift + Enter: to open links
Expand Down Expand Up @@ -27,13 +26,13 @@ KeyEventResult _openLinksHandler(
// A set to store the links which should be opened
final links = nodes
.map((node) => node.delta)
.whereNotNull()
.nonNulls
.expand(
(node) => node.map<String?>(
(op) => op.attributes?[AppFlowyRichTextKeys.href],
),
)
.whereNotNull()
.nonNulls
.toSet();

for (final link in links) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,11 @@ class _LinkEditFormState extends State<LinkEditForm> {
widget.hrefText.length,
{BuiltInAttributeKey.href: null},
);
await widget.editorState
.apply(transaction)
.whenComplete(() => Navigator.of(context).pop());
await widget.editorState.apply(transaction).whenComplete(() {
if (context.mounted) {
Navigator.of(context).pop();
}
});
},
),
TextButton(
Expand Down Expand Up @@ -206,8 +208,12 @@ class _LinkEditFormState extends State<LinkEditForm> {
},
);
await widget.editorState.apply(transaction).whenComplete(
() => Navigator.of(context).pop(),
);
() {
if (context.mounted) {
Navigator.of(context).pop();
}
},
);
} else if (textChanged && !addressChanged) {
final transaction = widget.editorState.transaction
..replaceText(
Expand All @@ -217,13 +223,21 @@ class _LinkEditFormState extends State<LinkEditForm> {
hrefTextTextEditingController.text,
);
await widget.editorState.apply(transaction).whenComplete(
() => Navigator.of(context).pop(),
);
() {
if (context.mounted) {
Navigator.of(context).pop();
}
},
);
} else if (!textChanged && addressChanged) {
await widget.editorState.formatDelta(widget.selection, {
AppFlowyRichTextKeys.href:
hrefAddressTextEditingController.value.text,
}).whenComplete(() => Navigator.of(context).pop());
}).whenComplete(() {
if (context.mounted) {
Navigator.of(context).pop();
}
});
} else {
Navigator.of(context).pop();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/editor/find_replace_menu/find_menu_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class FindReplaceMenu implements FindReplaceService {
BoxShadow(
blurRadius: 5,
spreadRadius: 1,
color: Colors.black.withOpacity(0.1),
color: Colors.black.withValues(alpha: 0.1),
),
],
borderRadius: BorderRadius.circular(6.0),
Expand Down
32 changes: 20 additions & 12 deletions lib/src/editor/find_replace_menu/find_replace_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,11 @@ class _FindMenuState extends State<FindMenu> {
// will request focus, here's a workaround to request the
// focus back to the findTextField
Future.delayed(const Duration(milliseconds: 50), () {
FocusScope.of(context).requestFocus(
findTextFieldFocusNode,
);
if (context.mounted) {
FocusScope.of(context).requestFocus(
findTextFieldFocusNode,
);
}
});
},
decoration: _buildInputDecoration(
Expand All @@ -255,9 +257,11 @@ class _FindMenuState extends State<FindMenu> {
onPressed: () {
// work around to request focus back to the input field
Future.delayed(const Duration(milliseconds: 10), () {
FocusScope.of(context).requestFocus(
findTextFieldFocusNode,
);
if (context.mounted) {
FocusScope.of(context).requestFocus(
findTextFieldFocusNode,
);
}
});
widget.searchService.navigateToMatch(moveUp: true);
},
Expand All @@ -270,9 +274,11 @@ class _FindMenuState extends State<FindMenu> {
iconButtonKey: const Key('nextMatchButton'),
onPressed: () {
Future.delayed(const Duration(milliseconds: 10), () {
FocusScope.of(context).requestFocus(
findTextFieldFocusNode,
);
if (context.mounted) {
FocusScope.of(context).requestFocus(
findTextFieldFocusNode,
);
}
});
widget.searchService.navigateToMatch();
},
Expand Down Expand Up @@ -400,9 +406,11 @@ class _ReplaceMenuState extends State<ReplaceMenu> {
_replaceSelectedWord();

Future.delayed(const Duration(milliseconds: 50), () {
FocusScope.of(context).requestFocus(
replaceTextFieldFocusNode,
);
if (context.mounted) {
FocusScope.of(context).requestFocus(
replaceTextFieldFocusNode,
);
}
});
},
decoration: _buildInputDecoration(
Expand Down
2 changes: 1 addition & 1 deletion lib/src/editor/selection_menu/selection_menu_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ class _SelectionMenuWidgetState extends State<SelectionMenuWidget> {
BoxShadow(
blurRadius: 5,
spreadRadius: 1,
color: Colors.black.withOpacity(0.1),
color: Colors.black.withValues(alpha: 0.1),
),
],
borderRadius: BorderRadius.circular(6.0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ BoxDecoration buildOverlayDecoration(BuildContext context) {
borderRadius: BorderRadius.circular(6),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
color: Colors.black.withValues(alpha: 0.2),
blurRadius: 10,
offset: const Offset(0, 2),
),
Expand Down
16 changes: 8 additions & 8 deletions lib/src/editor/toolbar/utils/color_generators.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,35 @@ List<ColorOption> generateTextColorOptions() {
List<ColorOption> generateHighlightColorOptions() {
return [
ColorOption(
colorHex: Colors.grey.withOpacity(0.3).toHex(),
colorHex: Colors.grey.withValues(alpha: 0.3).toHex(),
name: AppFlowyEditorL10n.current.backgroundColorGray,
),
ColorOption(
colorHex: Colors.brown.withOpacity(0.3).toHex(),
colorHex: Colors.brown.withValues(alpha: 0.3).toHex(),
name: AppFlowyEditorL10n.current.backgroundColorBrown,
),
ColorOption(
colorHex: Colors.yellow.withOpacity(0.3).toHex(),
colorHex: Colors.yellow.withValues(alpha: 0.3).toHex(),
name: AppFlowyEditorL10n.current.backgroundColorYellow,
),
ColorOption(
colorHex: Colors.green.withOpacity(0.3).toHex(),
colorHex: Colors.green.withValues(alpha: 0.3).toHex(),
name: AppFlowyEditorL10n.current.backgroundColorGreen,
),
ColorOption(
colorHex: Colors.blue.withOpacity(0.3).toHex(),
colorHex: Colors.blue.withValues(alpha: 0.3).toHex(),
name: AppFlowyEditorL10n.current.backgroundColorBlue,
),
ColorOption(
colorHex: Colors.purple.withOpacity(0.3).toHex(),
colorHex: Colors.purple.withValues(alpha: 0.3).toHex(),
name: AppFlowyEditorL10n.current.backgroundColorPurple,
),
ColorOption(
colorHex: Colors.pink.withOpacity(0.3).toHex(),
colorHex: Colors.pink.withValues(alpha: 0.3).toHex(),
name: AppFlowyEditorL10n.current.backgroundColorPink,
),
ColorOption(
colorHex: Colors.red.withOpacity(0.3).toHex(),
colorHex: Colors.red.withValues(alpha: 0.3).toHex(),
name: AppFlowyEditorL10n.current.backgroundColorRed,
),
];
Expand Down
7 changes: 6 additions & 1 deletion lib/src/editor/util/color_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ extension ColorExtension on String {

extension HexExtension on Color {
String toHex() {
return '0x${value.toRadixString(16)}';
final alpha = (a * 255).toInt().toRadixString(16).padLeft(2, '0');
final red = (r * 255).toInt().toRadixString(16).padLeft(2, '0');
final green = (g * 255).toInt().toRadixString(16).padLeft(2, '0');
final blue = (b * 255).toInt().toRadixString(16).padLeft(2, '0');

return '0x$alpha$red$green$blue'.toLowerCase();
}
}
Loading
Loading