feat: upgrade to Flutter 3.27.0 (#1020)

* chore: upgrade to Flutter 3.27.x

* chore: fix flutter analyze.

* chore: update changelog
This commit is contained in:
Lucas 2025-01-17 10:46:47 +08:00 • committed by GitHub
commit 70990e814c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 159 additions and 65 deletions

View file

@ -33,7 +33,7 @@ jobs:
- uses: subosito/flutter-action@v2 - uses: subosito/flutter-action@v2
with: with:
channel: "stable" channel: "stable"
flutter-version: "3.22.0" flutter-version: "3.27.0"
cache: true cache: true
- name: Run tests - name: Run tests

View file

@ -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 ## 4.0.0
- feat: support dragging to reorder block by @LucasXu0 in [#887](https://github.com/AppFlowy-IO/appflowy-editor/pull/887) - feat: support dragging to reorder block by @LucasXu0 in [#887](https://github.com/AppFlowy-IO/appflowy-editor/pull/887)

2
example/.gitignore vendored
View file

@ -5,9 +5,11 @@
*.swp *.swp
.DS_Store .DS_Store
.atom/ .atom/
.build/
.buildlog/ .buildlog/
.history .history
.svn/ .svn/
.swiftpm/
migrate_working_dir/ migrate_working_dir/
# IntelliJ related # IntelliJ related

View file

@ -158,7 +158,7 @@ class _CustomizeThemeForEditorState extends State<CustomizeThemeForEditor> {
: const EdgeInsets.symmetric(horizontal: 20), : const EdgeInsets.symmetric(horizontal: 20),
cursorColor: Colors.green, cursorColor: Colors.green,
dragHandleColor: Colors.green, dragHandleColor: Colors.green,
selectionColor: Colors.green.withOpacity(0.5), selectionColor: Colors.green.withValues(alpha: 0.5),
textStyleConfiguration: TextStyleConfiguration( textStyleConfiguration: TextStyleConfiguration(
text: GoogleFonts.poppins( text: GoogleFonts.poppins(
fontSize: 14.0, fontSize: 14.0,

View file

@ -130,7 +130,7 @@ class _EditorState extends State<Editor> {
child: Container( child: Container(
padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 12), padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 12),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.black.withOpacity(0.1), color: Colors.black.withValues(alpha: 0.1),
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
topLeft: const Radius.circular(8), topLeft: const Radius.circular(8),
bottomLeft: UniversalPlatform.isMobile bottomLeft: UniversalPlatform.isMobile

View file

@ -18,7 +18,7 @@ class _MarkdownEditorState extends State<MarkdownEditor> {
padding: const EdgeInsets.symmetric(horizontal: 16), padding: const EdgeInsets.symmetric(horizontal: 16),
cursorColor: Colors.transparent, cursorColor: Colors.transparent,
cursorWidth: 0, cursorWidth: 0,
selectionColor: Colors.grey.withOpacity(0.3), selectionColor: Colors.grey.withValues(alpha: 0.3),
textStyleConfiguration: TextStyleConfiguration( textStyleConfiguration: TextStyleConfiguration(
lineHeight: 1.2, lineHeight: 1.2,
applyHeightToFirstAscent: true, applyHeightToFirstAscent: true,

View file

@ -1,9 +1,13 @@
import Cocoa import Cocoa
import FlutterMacOS import FlutterMacOS
@NSApplicationMain @main
class AppDelegate: FlutterAppDelegate { class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true return true
} }
override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}
} }

View file

@ -1,5 +1,5 @@
/// AppFlowyEditor library /// AppFlowyEditor library
library appflowy_editor; library;
// core part, including document, node, selection, etc. // core part, including document, node, selection, etc.
export 'src/core/core.dart'; export 'src/core/core.dart';

View file

@ -117,7 +117,7 @@ class _UploadImageMenuState extends State<UploadImageMenu> {
BoxShadow( BoxShadow(
blurRadius: 5, blurRadius: 5,
spreadRadius: 1, spreadRadius: 1,
color: Colors.black.withOpacity(0.1), color: Colors.black.withValues(alpha: 0.1),
), ),
], ],
// borderRadius: BorderRadius.circular(6.0), // borderRadius: BorderRadius.circular(6.0),

View file

@ -210,7 +210,7 @@ class _ResizableImageState extends State<ResizableImage> {
child: Container( child: Container(
height: 40, height: 40,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.black.withOpacity(0.5), color: Colors.black.withValues(alpha: 0.5),
borderRadius: const BorderRadius.all( borderRadius: const BorderRadius.all(
Radius.circular(5.0), Radius.circular(5.0),
), ),

View file

@ -92,9 +92,6 @@ bool handleFormatByWrappingWithDoubleCharacter({
case DoubleCharacterFormatStyle.strikethrough: case DoubleCharacterFormatStyle.strikethrough:
style = 'strikethrough'; style = 'strikethrough';
break; break;
default:
style = '';
assert(false, 'Invalid format style');
} }
// if the text is already formatted, we should remove the format. // if the text is already formatted, we should remove the format.

View file

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

View file

@ -1,5 +1,4 @@
import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// Option/Alt + Shift + Enter: to open links /// Option/Alt + Shift + Enter: to open links
@ -27,13 +26,13 @@ KeyEventResult _openLinksHandler(
// A set to store the links which should be opened // A set to store the links which should be opened
final links = nodes final links = nodes
.map((node) => node.delta) .map((node) => node.delta)
.whereNotNull() .nonNulls
.expand( .expand(
(node) => node.map<String?>( (node) => node.map<String?>(
(op) => op.attributes?[AppFlowyRichTextKeys.href], (op) => op.attributes?[AppFlowyRichTextKeys.href],
), ),
) )
.whereNotNull() .nonNulls
.toSet(); .toSet();
for (final link in links) { for (final link in links) {

View file

@ -175,9 +175,11 @@ class _LinkEditFormState extends State<LinkEditForm> {
widget.hrefText.length, widget.hrefText.length,
{BuiltInAttributeKey.href: null}, {BuiltInAttributeKey.href: null},
); );
await widget.editorState await widget.editorState.apply(transaction).whenComplete(() {
.apply(transaction) if (context.mounted) {
.whenComplete(() => Navigator.of(context).pop()); Navigator.of(context).pop();
}
});
}, },
), ),
TextButton( TextButton(
@ -206,8 +208,12 @@ class _LinkEditFormState extends State<LinkEditForm> {
}, },
); );
await widget.editorState.apply(transaction).whenComplete( await widget.editorState.apply(transaction).whenComplete(
() => Navigator.of(context).pop(), () {
); if (context.mounted) {
Navigator.of(context).pop();
}
},
);
} else if (textChanged && !addressChanged) { } else if (textChanged && !addressChanged) {
final transaction = widget.editorState.transaction final transaction = widget.editorState.transaction
..replaceText( ..replaceText(
@ -217,13 +223,21 @@ class _LinkEditFormState extends State<LinkEditForm> {
hrefTextTextEditingController.text, hrefTextTextEditingController.text,
); );
await widget.editorState.apply(transaction).whenComplete( await widget.editorState.apply(transaction).whenComplete(
() => Navigator.of(context).pop(), () {
); if (context.mounted) {
Navigator.of(context).pop();
}
},
);
} else if (!textChanged && addressChanged) { } else if (!textChanged && addressChanged) {
await widget.editorState.formatDelta(widget.selection, { await widget.editorState.formatDelta(widget.selection, {
AppFlowyRichTextKeys.href: AppFlowyRichTextKeys.href:
hrefAddressTextEditingController.value.text, hrefAddressTextEditingController.value.text,
}).whenComplete(() => Navigator.of(context).pop()); }).whenComplete(() {
if (context.mounted) {
Navigator.of(context).pop();
}
});
} else { } else {
Navigator.of(context).pop(); Navigator.of(context).pop();
} }

View file

@ -89,7 +89,7 @@ class FindReplaceMenu implements FindReplaceService {
BoxShadow( BoxShadow(
blurRadius: 5, blurRadius: 5,
spreadRadius: 1, spreadRadius: 1,
color: Colors.black.withOpacity(0.1), color: Colors.black.withValues(alpha: 0.1),
), ),
], ],
borderRadius: BorderRadius.circular(6.0), borderRadius: BorderRadius.circular(6.0),

View file

@ -230,9 +230,11 @@ class _FindMenuState extends State<FindMenu> {
// will request focus, here's a workaround to request the // will request focus, here's a workaround to request the
// focus back to the findTextField // focus back to the findTextField
Future.delayed(const Duration(milliseconds: 50), () { Future.delayed(const Duration(milliseconds: 50), () {
FocusScope.of(context).requestFocus( if (context.mounted) {
findTextFieldFocusNode, FocusScope.of(context).requestFocus(
); findTextFieldFocusNode,
);
}
}); });
}, },
decoration: _buildInputDecoration( decoration: _buildInputDecoration(
@ -255,9 +257,11 @@ class _FindMenuState extends State<FindMenu> {
onPressed: () { onPressed: () {
// work around to request focus back to the input field // work around to request focus back to the input field
Future.delayed(const Duration(milliseconds: 10), () { Future.delayed(const Duration(milliseconds: 10), () {
FocusScope.of(context).requestFocus( if (context.mounted) {
findTextFieldFocusNode, FocusScope.of(context).requestFocus(
); findTextFieldFocusNode,
);
}
}); });
widget.searchService.navigateToMatch(moveUp: true); widget.searchService.navigateToMatch(moveUp: true);
}, },
@ -270,9 +274,11 @@ class _FindMenuState extends State<FindMenu> {
iconButtonKey: const Key('nextMatchButton'), iconButtonKey: const Key('nextMatchButton'),
onPressed: () { onPressed: () {
Future.delayed(const Duration(milliseconds: 10), () { Future.delayed(const Duration(milliseconds: 10), () {
FocusScope.of(context).requestFocus( if (context.mounted) {
findTextFieldFocusNode, FocusScope.of(context).requestFocus(
); findTextFieldFocusNode,
);
}
}); });
widget.searchService.navigateToMatch(); widget.searchService.navigateToMatch();
}, },
@ -400,9 +406,11 @@ class _ReplaceMenuState extends State<ReplaceMenu> {
_replaceSelectedWord(); _replaceSelectedWord();
Future.delayed(const Duration(milliseconds: 50), () { Future.delayed(const Duration(milliseconds: 50), () {
FocusScope.of(context).requestFocus( if (context.mounted) {
replaceTextFieldFocusNode, FocusScope.of(context).requestFocus(
); replaceTextFieldFocusNode,
);
}
}); });
}, },
decoration: _buildInputDecoration( decoration: _buildInputDecoration(

View file

@ -343,7 +343,7 @@ class _SelectionMenuWidgetState extends State<SelectionMenuWidget> {
BoxShadow( BoxShadow(
blurRadius: 5, blurRadius: 5,
spreadRadius: 1, spreadRadius: 1,
color: Colors.black.withOpacity(0.1), color: Colors.black.withValues(alpha: 0.1),
), ),
], ],
borderRadius: BorderRadius.circular(6.0), borderRadius: BorderRadius.circular(6.0),

View file

@ -20,7 +20,7 @@ BoxDecoration buildOverlayDecoration(BuildContext context) {
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(6),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Colors.black.withOpacity(0.2), color: Colors.black.withValues(alpha: 0.2),
blurRadius: 10, blurRadius: 10,
offset: const Offset(0, 2), offset: const Offset(0, 2),
), ),

View file

@ -53,35 +53,35 @@ List<ColorOption> generateTextColorOptions() {
List<ColorOption> generateHighlightColorOptions() { List<ColorOption> generateHighlightColorOptions() {
return [ return [
ColorOption( ColorOption(
colorHex: Colors.grey.withOpacity(0.3).toHex(), colorHex: Colors.grey.withValues(alpha: 0.3).toHex(),
name: AppFlowyEditorL10n.current.backgroundColorGray, name: AppFlowyEditorL10n.current.backgroundColorGray,
), ),
ColorOption( ColorOption(
colorHex: Colors.brown.withOpacity(0.3).toHex(), colorHex: Colors.brown.withValues(alpha: 0.3).toHex(),
name: AppFlowyEditorL10n.current.backgroundColorBrown, name: AppFlowyEditorL10n.current.backgroundColorBrown,
), ),
ColorOption( ColorOption(
colorHex: Colors.yellow.withOpacity(0.3).toHex(), colorHex: Colors.yellow.withValues(alpha: 0.3).toHex(),
name: AppFlowyEditorL10n.current.backgroundColorYellow, name: AppFlowyEditorL10n.current.backgroundColorYellow,
), ),
ColorOption( ColorOption(
colorHex: Colors.green.withOpacity(0.3).toHex(), colorHex: Colors.green.withValues(alpha: 0.3).toHex(),
name: AppFlowyEditorL10n.current.backgroundColorGreen, name: AppFlowyEditorL10n.current.backgroundColorGreen,
), ),
ColorOption( ColorOption(
colorHex: Colors.blue.withOpacity(0.3).toHex(), colorHex: Colors.blue.withValues(alpha: 0.3).toHex(),
name: AppFlowyEditorL10n.current.backgroundColorBlue, name: AppFlowyEditorL10n.current.backgroundColorBlue,
), ),
ColorOption( ColorOption(
colorHex: Colors.purple.withOpacity(0.3).toHex(), colorHex: Colors.purple.withValues(alpha: 0.3).toHex(),
name: AppFlowyEditorL10n.current.backgroundColorPurple, name: AppFlowyEditorL10n.current.backgroundColorPurple,
), ),
ColorOption( ColorOption(
colorHex: Colors.pink.withOpacity(0.3).toHex(), colorHex: Colors.pink.withValues(alpha: 0.3).toHex(),
name: AppFlowyEditorL10n.current.backgroundColorPink, name: AppFlowyEditorL10n.current.backgroundColorPink,
), ),
ColorOption( ColorOption(
colorHex: Colors.red.withOpacity(0.3).toHex(), colorHex: Colors.red.withValues(alpha: 0.3).toHex(),
name: AppFlowyEditorL10n.current.backgroundColorRed, name: AppFlowyEditorL10n.current.backgroundColorRed,
), ),
]; ];

View file

@ -49,6 +49,11 @@ extension ColorExtension on String {
extension HexExtension on Color { extension HexExtension on Color {
String toHex() { 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();
} }
} }

Some files were not shown because too many files have changed in this diff Show more