diff --git a/example/lib/main.dart b/example/lib/main.dart index a245c5f..7b75b5e 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -10,7 +10,7 @@ void main() { } class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); + const MyApp({super.key}); // This widget is the root of your application. @override @@ -28,7 +28,7 @@ class MyApp extends StatelessWidget { } class MyHomePage extends StatefulWidget { - const MyHomePage({Key? key, required this.title}) : super(key: key); + const MyHomePage({super.key, required this.title}); // This widget is the home page of your application. It is stateful, meaning // that it has a State object (defined below) that contains fields that affect diff --git a/example/lib/menu.dart b/example/lib/menu.dart index 8778eb1..808c6e8 100644 --- a/example/lib/menu.dart +++ b/example/lib/menu.dart @@ -4,11 +4,10 @@ import 'package:re_editor/re_editor.dart'; class ContextMenuItemWidget extends PopupMenuItem implements PreferredSizeWidget { ContextMenuItemWidget({ - Key? key, + super.key, required String text, required VoidCallback onTap, }) : super( - key: key, onTap: onTap, child: Text(text) ); diff --git a/example/pubspec.lock b/example/pubspec.lock index 53164fc..b63a7ec 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,26 +5,26 @@ packages: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37 url: "https://pub.dev" source: hosted - version: "2.11.0" + version: "2.13.1" characters: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.1" collection: dependency: "direct main" description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.19.1" flutter: dependency: "direct main" description: flutter @@ -38,22 +38,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.3" - isolate_contactor: - dependency: transitive - description: - name: isolate_contactor - sha256: "6ba8434ceb58238a1389d6365111a3efe7baa1c68a66f4db6d63d351cf6c3a0f" - url: "https://pub.dev" - source: hosted - version: "4.1.0" isolate_manager: dependency: transitive description: name: isolate_manager - sha256: "22ed0c25f80ec3b5f21e3a55d060f4650afff33f27c2dff34c0f9409d5759ae5" + sha256: "806b6195a60f17bcb23e3c6d2f4da1f29e7376c4295b061d135f59613586ad1d" url: "https://pub.dev" source: hosted - version: "4.1.5+1" + version: "6.3.2" lints: dependency: transitive description: @@ -66,33 +58,33 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" url: "https://pub.dev" source: hosted - version: "0.8.0" + version: "0.13.0" meta: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.18.0" path: dependency: transitive description: name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.9.1" re_editor: dependency: "direct main" description: path: ".." relative: true source: path - version: "0.9.0" + version: "0.10.0" re_highlight: dependency: "direct main" description: @@ -105,23 +97,31 @@ packages: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" stream_channel: dependency: transitive description: name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" vector_math: dependency: transitive description: name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b url: "https://pub.dev" source: hosted - version: "2.1.4" + version: "2.2.0" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" + source: hosted + version: "1.1.1" sdks: - dart: ">=3.2.0-0 <4.0.0" + dart: ">=3.12.2 <4.0.0" flutter: ">=1.17.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index c022198..098f96c 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -5,8 +5,7 @@ publish_to: none version: 1.0.0 environment: - sdk: ">=2.17.0 <3.0.0" - flutter: ">=1.17.0" + sdk: ">=3.12.2 <4.0.0" dependencies: flutter: diff --git a/lib/src/_code_autocomplete.dart b/lib/src/_code_autocomplete.dart index fae1006..79ceadc 100644 --- a/lib/src/_code_autocomplete.dart +++ b/lib/src/_code_autocomplete.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; class _DefaultCodeAutocompletePromptsBuilder implements DefaultCodeAutocompletePromptsBuilder { diff --git a/lib/src/_code_editable.dart b/lib/src/_code_editable.dart index 365f6d7..4077a8b 100644 --- a/lib/src/_code_editable.dart +++ b/lib/src/_code_editable.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; const double _kDefaultTextSize = 13.0; const double _kDefaultFontHeight = 1.4; @@ -245,8 +245,7 @@ class _CodeEditableState extends State<_CodeEditable> with AutomaticKeepAliveCli child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (indicator != null) - indicator, + ?indicator, if (widget.leadingDivider != null) widget.leadingDivider!, Expanded( diff --git a/lib/src/_code_extensions.dart b/lib/src/_code_extensions.dart index ef8a7ec..a79205c 100644 --- a/lib/src/_code_extensions.dart +++ b/lib/src/_code_extensions.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; extension _InlineSpanExtension on InlineSpan { diff --git a/lib/src/_code_field.dart b/lib/src/_code_field.dart index f5d4ff9..3cdc833 100644 --- a/lib/src/_code_field.dart +++ b/lib/src/_code_field.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; class _CodeField extends SingleChildRenderObjectWidget { @@ -158,54 +158,36 @@ class _CodeFieldRender extends RenderBox implements MouseTrackerAnnotation { late double _preferredLineHeight; _CodeFieldRender({ - required ViewportOffset verticalViewport, - required ViewportOffset? horizontalViewport, - required double verticalScrollbarWidth, - required double horizontalScrollbarHeight, - required CodeLines codes, - required CodeLineSelection selection, + required this._verticalViewport, + required this._horizontalViewport, + required this._verticalScrollbarWidth, + required this._horizontalScrollbarHeight, + required this._codes, + required this._selection, required List? highlightSelections, - required TextStyle textStyle, - required bool hasFocus, - required _CodeHighlighter highlighter, - required ValueNotifier showCursorNotifier, - required ValueNotifier<_FloatingCursorState> floatingCursorNotifier, - required ValueChanged> onRenderParagraphsChanged, + required this._textStyle, + required this._hasFocus, + required this._highlighter, + required this._showCursorNotifier, + required this._floatingCursorNotifier, + required this._onRenderParagraphsChanged, required Color selectionColor, required Color highlightColor, required Color cursorColor, required Color floatingCursorColor, Color? cursorLineColor, - Color? chunkIndicatorColor, + this._chunkIndicatorColor, required double cursorWidth, required double floatingCursorWidth, - required EdgeInsetsGeometry padding, - required bool readOnly, - int? maxLengthSingleLineRendering, - required LayerLink startHandleLayerLink, - required LayerLink endHandleLayerLink, - }) : _verticalViewport = verticalViewport, - _horizontalViewport = horizontalViewport, - _verticalScrollbarWidth = verticalScrollbarWidth, - _horizontalScrollbarHeight = horizontalScrollbarHeight, - _codes = codes, - _selection = selection, - _textStyle = textStyle, - _hasFocus = hasFocus, - _highlighter = highlighter, - _showCursorNotifier = showCursorNotifier, - _floatingCursorNotifier = floatingCursorNotifier, - _onRenderParagraphsChanged = onRenderParagraphsChanged, - _padding = padding, - _readOnly = readOnly, - _maxLengthSingleLineRendering = maxLengthSingleLineRendering, - _chunkIndicatorColor = chunkIndicatorColor, - _paint = Paint(), + required this._padding, + required this._readOnly, + this._maxLengthSingleLineRendering, + required this._startHandleLayerLink, + required this._endHandleLayerLink, + }) : _paint = Paint(), _displayParagraphs = [], _chunkIndicators = [], - _cursor = SystemMouseCursors.text, - _startHandleLayerLink = startHandleLayerLink, - _endHandleLayerLink = endHandleLayerLink { + _cursor = SystemMouseCursors.text { _backgroundRender = _CodeFieldExtraRender( painters: [ _CodeCursorLinePainter(cursorLineColor, _selection), @@ -1426,7 +1408,7 @@ class _CodeCursorLinePainter extends _CodeFieldExtraPainter { @override void paint(Canvas canvas, Size size, _CodeFieldRender render) { - if (_color == null || _color == Colors.transparent || _color!.alpha == 0) { + if (_color == null || _color == Colors.transparent || _color!.a == 0.0) { return; } if (!_selection.isCollapsed) { @@ -1480,7 +1462,7 @@ abstract class _CodeFieldSelectionsPainter extends _CodeFieldExtraPainter { @override void paint(Canvas canvas, Size size, _CodeFieldRender render) { - if (_color == Colors.transparent || _color.alpha == 0) { + if (_color == Colors.transparent || _color.a == 0.0) { return; } final List paragraphs = render.displayParagraphs; @@ -1575,17 +1557,12 @@ class _CodeFieldCursorPainter extends _CodeFieldExtraPainter { bool _willDraw; _CodeFieldCursorPainter({ - required CodeLinePosition position, - required Color color, - required double width, - required double height, - required bool visible, - }) : _position = position, - _color = color, - _width = width, - _height = height, - _visible = visible, - _willDraw = true, + required this._position, + required this._color, + required this._width, + required this._height, + required this._visible, + }) : _willDraw = true, _paint = Paint(); set position(CodeLinePosition value) { @@ -1640,7 +1617,7 @@ class _CodeFieldCursorPainter extends _CodeFieldExtraPainter { @override void paint(Canvas canvas, Size size, _CodeFieldRender render) { - if (!_visible || !_willDraw || _color == Colors.transparent || _color.alpha == 0) { + if (!_visible || !_willDraw || _color == Colors.transparent || _color.a == 0.0) { return; } final CodeLineRenderParagraph? paragraph = render.findDisplayParagraphByLineIndex(_position.index); @@ -1674,15 +1651,11 @@ class _CodeFieldFloatingCursorPainter extends _CodeFieldExtraPainter { double _height; _CodeFieldFloatingCursorPainter({ - required _FloatingCursorState position, - required Color color, - required double width, - required double height, - }) : _position = position, - _color = color, - _width = width, - _height = height, - _paint = Paint(); + required this._position, + required this._color, + required this._width, + required this._height, + }) : _paint = Paint(); set position(_FloatingCursorState value) { if (_position == value) { @@ -1722,7 +1695,7 @@ class _CodeFieldFloatingCursorPainter extends _CodeFieldExtraPainter { @override void paint(Canvas canvas, Size size, _CodeFieldRender render) { - if (!_position.isActive() || _color == Colors.transparent || _color.alpha == 0) { + if (!_position.isActive() || _color == Colors.transparent || _color.a == 0.0) { return; } _drawFloatingCaret(canvas, _position.floatingCursorOffset!, size); diff --git a/lib/src/_code_find.dart b/lib/src/_code_find.dart index e579503..1c654d7 100644 --- a/lib/src/_code_find.dart +++ b/lib/src/_code_find.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; class _CodeFindControllerImpl extends ValueNotifier implements CodeFindController { diff --git a/lib/src/_code_floating_cursor.dart b/lib/src/_code_floating_cursor.dart index caa31b7..a286e72 100644 --- a/lib/src/_code_floating_cursor.dart +++ b/lib/src/_code_floating_cursor.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; // The time the animation of the floating cursor snapping to the final cursor position will take. const Duration floatingCursorSnapDuration = Duration(milliseconds: 300); diff --git a/lib/src/_code_formatter.dart b/lib/src/_code_formatter.dart index 9c19820..6fac33e 100644 --- a/lib/src/_code_formatter.dart +++ b/lib/src/_code_formatter.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; class _DefaultCodeCommentFormatter implements DefaultCodeCommentFormatter { diff --git a/lib/src/_code_highlight.dart b/lib/src/_code_highlight.dart index 6c6af79..a1e5a94 100644 --- a/lib/src/_code_highlight.dart +++ b/lib/src/_code_highlight.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; class _CodeHighlighter extends ValueNotifier> { @@ -10,12 +10,10 @@ class _CodeHighlighter extends ValueNotifier> { CodeHighlightTheme? _theme; _CodeHighlighter({ - required BuildContext context, - required CodeLineEditingController controller, + required this._context, + required this._controller, CodeHighlightTheme? theme, - }) : _context = context, - _provider = _CodeParagraphProvider(), - _controller = controller, + }) : _provider = _CodeParagraphProvider(), _theme = theme, _engine = _CodeHighlightEngine(theme), super(const []) { @@ -122,8 +120,7 @@ class _CodeHighlighter extends ValueNotifier> { } return _buildSpanFromNodes([ ...startNodes, - if (midNode != null) - midNode, + ?midNode, ...endNodes ], style); } diff --git a/lib/src/_code_indicator.dart b/lib/src/_code_indicator.dart index 4393f41..9dbbf8e 100644 --- a/lib/src/_code_indicator.dart +++ b/lib/src/_code_indicator.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; class CodeLineNumberRenderObject extends RenderBox { @@ -14,16 +14,12 @@ class CodeLineNumberRenderObject extends RenderBox { CodeLineNumberRenderObject({ required CodeLineEditingController controller, - required CodeIndicatorValueNotifier notifier, - required TextStyle textStyle, - required TextStyle focusedTextStyle, - required int minNumberCount, + required this._notifier, + required this._textStyle, + required this._focusedTextStyle, + required this._minNumberCount, String Function(int lineIndex)? custonLineIndex2Text, }) : _controller = controller, - _notifier = notifier, - _textStyle = textStyle, - _focusedTextStyle = focusedTextStyle, - _minNumberCount = minNumberCount, _allLineCount = controller.lineCount, _customLineIndex2Text = custonLineIndex2Text, _textPainter = TextPainter( @@ -184,19 +180,13 @@ class CodeChunkIndicatorRenderObject extends RenderBox implements MouseTrackerAn MouseCursor _cursor; CodeChunkIndicatorRenderObject({ - required double width, - required CodeChunkController controller, - required CodeIndicatorValueNotifier notifier, - required CodeChunkIndicatorPainter painter, - required bool collapseIndicatorVisible, - required bool expandIndicatorVisible, - }) : _width = width, - _controller = controller, - _notifier = notifier, - _painter = painter, - _collapseIndicatorVisible = collapseIndicatorVisible, - _expandIndicatorVisible = expandIndicatorVisible, - _cursor = MouseCursor.defer; + required this._width, + required this._controller, + required this._notifier, + required this._painter, + required this._collapseIndicatorVisible, + required this._expandIndicatorVisible, + }) : _cursor = MouseCursor.defer; set width(double value) { if (_width == value) { diff --git a/lib/src/_code_input.dart b/lib/src/_code_input.dart index 5b74002..11cf387 100644 --- a/lib/src/_code_input.dart +++ b/lib/src/_code_input.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; class _CodeInputController extends ChangeNotifier implements DeltaTextInputClient { @@ -18,17 +18,12 @@ class _CodeInputController extends ChangeNotifier implements DeltaTextInputClien GlobalKey? _editorKey; _CodeInputController({ - required CodeLineEditingController controller, - required _CodeFloatingCursorController floatingCursorController, - required FocusNode focusNode, - required bool readOnly, - required bool autocompleteSymbols, - }) : _controller = controller, - _floatingCursorController = floatingCursorController, - _focusNode = focusNode, - _readOnly = readOnly, - _updateCausedByFloatingCursor = false, - _autocompleteSymbols = autocompleteSymbols { + required this._controller, + required this._floatingCursorController, + required this._focusNode, + required this._readOnly, + required this._autocompleteSymbols, + }) : _updateCausedByFloatingCursor = false { _controller.addListener(_onCodeEditingChanged); _focusNode.addListener(_onFocusChanged); } @@ -320,6 +315,7 @@ class _CodeInputController extends ChangeNotifier implements DeltaTextInputClien void insertContent(KeyboardInsertedContent content) { } + @override bool onFocusReceived() => false; void ensureInput() { diff --git a/lib/src/_code_line.dart b/lib/src/_code_line.dart index 1ad82d6..50b0e3a 100644 --- a/lib/src/_code_line.dart +++ b/lib/src/_code_line.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; const CodeLines _kInitialCodeLines = CodeLines([ CodeLineSegment(codeLines: [ diff --git a/lib/src/_code_lines.dart b/lib/src/_code_lines.dart index 20f39a5..dd49eed 100644 --- a/lib/src/_code_lines.dart +++ b/lib/src/_code_lines.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; class _CodeLineSegmentQuckLineCount extends CodeLineSegment { diff --git a/lib/src/_code_paragraph.dart b/lib/src/_code_paragraph.dart index d975fed..caca0f6 100644 --- a/lib/src/_code_paragraph.dart +++ b/lib/src/_code_paragraph.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; class _ParagraphImpl extends IParagraph { @@ -19,10 +19,9 @@ class _ParagraphImpl extends IParagraph { required this.text, required this.span, required this.paragraph, - required bool trucated, + required this._trucated, required double preferredLineHeight, - }) : _trucated = trucated, - _preferredLineHeight = preferredLineHeight, + }) : _preferredLineHeight = preferredLineHeight, _lineCount = (paragraph.height / preferredLineHeight).ceil(); int get runeLength => text.runes.length; diff --git a/lib/src/_code_scroll.dart b/lib/src/_code_scroll.dart index 9ee525c..e531f26 100644 --- a/lib/src/_code_scroll.dart +++ b/lib/src/_code_scroll.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; const double _kScrollbarThickness = 8.0; @@ -81,18 +81,16 @@ class _RawScrollbar extends RawScrollbar { const _RawScrollbar({ required this.physics, - required Widget child, + required super.child, required ScrollController controller, - ScrollbarOrientation? scrollbarOrientation, + super.scrollbarOrientation, required bool thumbVisibility, }) : super( controller: controller, - scrollbarOrientation: scrollbarOrientation, thumbVisibility: thumbVisibility, thickness: _kScrollbarThickness, radius: const Radius.circular(10), crossAxisMargin: 2, - child: child, ); @override diff --git a/lib/src/_code_selection.dart b/lib/src/_code_selection.dart index 449b308..b7995b6 100644 --- a/lib/src/_code_selection.dart +++ b/lib/src/_code_selection.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; class _CodeSelectionGestureDetector extends StatefulWidget { diff --git a/lib/src/_code_shortcuts.dart b/lib/src/_code_shortcuts.dart index 76b10be..3c3e293 100644 --- a/lib/src/_code_shortcuts.dart +++ b/lib/src/_code_shortcuts.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; class _CodeShortcuts extends StatefulWidget { final CodeShortcutsActivatorsBuilder builder; @@ -108,7 +108,7 @@ class _CodeShortcutActions extends StatelessWidget { DoNothingAndStopPropagationTextIntent: DoNothingAction(consumesKey: false), }, - if (overrideActions != null) ...overrideActions! + ...?overrideActions }, child: child); } diff --git a/lib/src/_code_span.dart b/lib/src/_code_span.dart index 700facc..54d71e9 100644 --- a/lib/src/_code_span.dart +++ b/lib/src/_code_span.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; @immutable class _MouseTrackerAnnotationTextSpan extends TextSpan { diff --git a/lib/src/_consts.dart b/lib/src/_consts.dart index 3d978db..0b2cd6e 100644 --- a/lib/src/_consts.dart +++ b/lib/src/_consts.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; final kIsMacOS = defaultTargetPlatform == TargetPlatform.macOS; final kIsAndroid = defaultTargetPlatform == TargetPlatform.android; diff --git a/lib/src/_isolate.dart b/lib/src/_isolate.dart index ffd4bae..1068b37 100644 --- a/lib/src/_isolate.dart +++ b/lib/src/_isolate.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; typedef IsolateRunnable = Res Function(Req req); typedef IsolateCallback = void Function(Res res); diff --git a/lib/src/code_autocomplete.dart b/lib/src/code_autocomplete.dart index 4e924c6..60f9c6a 100644 --- a/lib/src/code_autocomplete.dart +++ b/lib/src/code_autocomplete.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; /// Define code autocomplate prompt information. /// diff --git a/lib/src/code_chunk.dart b/lib/src/code_chunk.dart index f964f99..5f0ade5 100644 --- a/lib/src/code_chunk.dart +++ b/lib/src/code_chunk.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; class CodeChunkController extends ValueNotifier> { diff --git a/lib/src/code_editor.dart b/lib/src/code_editor.dart index f23d031..18dd33c 100644 --- a/lib/src/code_editor.dart +++ b/lib/src/code_editor.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; /// An immutable style describing how to format and paint editor content. class CodeEditorStyle { @@ -515,8 +515,8 @@ class _CodeEditorState extends State { ), hintTextColor: widget.style?.hintTextColor, backgroundColor: widget.style?.backgroundColor, - selectionColor: widget.style?.selectionColor ?? selectionTheme.selectionColor ?? theme.colorScheme.primary.withOpacity(0.4), - highlightColor: widget.style?.highlightColor ?? selectionTheme.selectionColor ?? theme.colorScheme.primary.withOpacity(0.4), + selectionColor: widget.style?.selectionColor ?? selectionTheme.selectionColor ?? theme.colorScheme.primary.withValues(alpha: 0.4), + highlightColor: widget.style?.highlightColor ?? selectionTheme.selectionColor ?? theme.colorScheme.primary.withValues(alpha: 0.4), cursorColor: widget.style?.cursorColor ?? selectionTheme.cursorColor ?? theme.colorScheme.primary, cursorLineColor: widget.style?.cursorLineColor, chunkIndicatorColor: widget.style?.chunkIndicatorColor, @@ -562,11 +562,11 @@ class _CodeEditorState extends State { child = Focus( autofocus: autofocus, focusNode: _focusNode, - onKey: (node, event) { - if (event.isKeyPressed(LogicalKeyboardKey.backspace)) { + onKeyEvent: (node, event) { + if (HardwareKeyboard.instance.isLogicalKeyPressed(LogicalKeyboardKey.backspace)) { _editingController.deleteBackward(); return KeyEventResult.handled; - } else if (event.isKeyPressed(LogicalKeyboardKey.enter)) { + } else if (HardwareKeyboard.instance.isLogicalKeyPressed(LogicalKeyboardKey.enter)) { _editingController.applyNewLine(); return KeyEventResult.handled; } @@ -599,8 +599,7 @@ class _CodeEditorState extends State { return Stack( children: [ child, - if (find != null) - find, + ?find, ], ); } diff --git a/lib/src/code_find.dart b/lib/src/code_find.dart index 911aaa5..2819d63 100644 --- a/lib/src/code_find.dart +++ b/lib/src/code_find.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; typedef CodeFindBuilder = PreferredSizeWidget Function(BuildContext context, CodeFindController controller, bool readonly); diff --git a/lib/src/code_formatter.dart b/lib/src/code_formatter.dart index 2df6422..e5ffbbf 100644 --- a/lib/src/code_formatter.dart +++ b/lib/src/code_formatter.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; abstract class CodeCommentFormatter { diff --git a/lib/src/code_indicator.dart b/lib/src/code_indicator.dart index 63fc81a..1e20513 100644 --- a/lib/src/code_indicator.dart +++ b/lib/src/code_indicator.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; const int _kDefaultMinNumberCount = 3; const Size _kDefaultChunkIndicatorSize = Size(7, 7); diff --git a/lib/src/code_line.dart b/lib/src/code_line.dart index 4f7d107..9b0038b 100644 --- a/lib/src/code_line.dart +++ b/lib/src/code_line.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; typedef CodeLineSpanBuilder = TextSpan Function({ required BuildContext context, diff --git a/lib/src/code_lines.dart b/lib/src/code_lines.dart index d07a77d..40a92df 100644 --- a/lib/src/code_lines.dart +++ b/lib/src/code_lines.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; const int _kCodeLineSegamentDefaultSize = 256; diff --git a/lib/src/code_paragraph.dart b/lib/src/code_paragraph.dart index 67021ed..c5191fd 100644 --- a/lib/src/code_paragraph.dart +++ b/lib/src/code_paragraph.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; abstract class IParagraph { diff --git a/lib/src/code_scroll.dart b/lib/src/code_scroll.dart index a8d15e7..c1ff87d 100644 --- a/lib/src/code_scroll.dart +++ b/lib/src/code_scroll.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; typedef CodeScrollbarBuilder = Widget Function(BuildContext context, Widget child, ScrollableDetails details); diff --git a/lib/src/code_shortcuts.dart b/lib/src/code_shortcuts.dart index 08315b2..8d364c5 100644 --- a/lib/src/code_shortcuts.dart +++ b/lib/src/code_shortcuts.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; enum CodeShortcutType { selectAll, diff --git a/lib/src/code_span.dart b/lib/src/code_span.dart index f01d9a3..747e3a7 100644 --- a/lib/src/code_span.dart +++ b/lib/src/code_span.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; typedef PointerEnterEventWithRectListener = void Function(PointerEnterEvent event, int id, List rects); diff --git a/lib/src/code_theme.dart b/lib/src/code_theme.dart index 545d531..c7f9e54 100644 --- a/lib/src/code_theme.dart +++ b/lib/src/code_theme.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; /// The code syntax highlighting theme. We use Re-Highlight as the syntax highlighting rule. /// Re-Highlight provides some built-in syntax highlighting rules for dozens of programming languages, diff --git a/lib/src/code_toolbar.dart b/lib/src/code_toolbar.dart index 5b2948f..2d78d0e 100644 --- a/lib/src/code_toolbar.dart +++ b/lib/src/code_toolbar.dart @@ -1,4 +1,4 @@ -part of re_editor; +part of 're_editor.dart'; typedef ToolbarMenuBuilder = Widget Function({ required BuildContext context, diff --git a/lib/src/debug/_trace.dart b/lib/src/debug/_trace.dart deleted file mode 100644 index 496ed30..0000000 --- a/lib/src/debug/_trace.dart +++ /dev/null @@ -1,22 +0,0 @@ -part of re_editor; - -class _Trace { - - static final Map _timestamps = {}; - - static void begin(String name) { - _timestamps[name] = DateTime.now(); - } - - static void end(String name, [bool microsecond = false]) { - final DateTime? time = _timestamps.remove(name); - if (time != null) { - if (microsecond) { - print('[${DateTime.now()}] $name costs ${DateTime.now().microsecondsSinceEpoch - time.microsecondsSinceEpoch} us'); - } else { - print('[${DateTime.now()}] $name costs ${DateTime.now().millisecondsSinceEpoch - time.millisecondsSinceEpoch} ms'); - } - } - } - -} \ No newline at end of file diff --git a/lib/src/re_editor.dart b/lib/src/re_editor.dart index 72a8a90..96cec0f 100644 --- a/lib/src/re_editor.dart +++ b/lib/src/re_editor.dart @@ -1,5 +1,3 @@ -library re_editor; - import 'dart:async'; import 'dart:math'; import 'dart:ui' as ui; @@ -48,5 +46,4 @@ part 'code_shortcuts.dart'; part 'code_scroll.dart'; part 'code_span.dart'; part 'code_theme.dart'; -part 'code_toolbar.dart'; -part 'debug/_trace.dart'; \ No newline at end of file +part 'code_toolbar.dart'; \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 99678a6..ebc2391 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,16 +5,16 @@ homepage: https://reqable.com repository: https://github.com/reqable/re-editor environment: - sdk: ">=2.17.3 <4.0.0" + sdk: ">=3.12.2 <4.0.0" dependencies: flutter: sdk: flutter re_highlight: ^0.0.3 - isolate_manager: ^4.1.5+1 + isolate_manager: ^6.3.2 dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.1 + flutter_lints: ^6.0.0 path: ^1.8.2 \ No newline at end of file