Format code

pull/289/head
Cheryl Zhang 4 years ago
parent 6b9795ad00
commit 0c5a045d28
  1. 3
      lib/src/widgets/raw_editor.dart
  2. 6
      lib/src/widgets/text_selection.dart

@ -140,8 +140,7 @@ class RawEditorState extends EditorState
super.build(context); super.build(context);
var _doc = widget.controller.document; var _doc = widget.controller.document;
if (_doc.isEmpty() && if (_doc.isEmpty() && widget.placeholder != null) {
widget.placeholder != null) {
_doc = Document.fromJson(jsonDecode( _doc = Document.fromJson(jsonDecode(
'[{"attributes":{"placeholder":true},"insert":"${widget.placeholder}\\n"}]')); '[{"attributes":{"placeholder":true},"insert":"${widget.placeholder}\\n"}]'));
} }

@ -287,7 +287,6 @@ class _TextSelectionHandleOverlay extends StatefulWidget {
class _TextSelectionHandleOverlayState class _TextSelectionHandleOverlayState
extends State<_TextSelectionHandleOverlay> extends State<_TextSelectionHandleOverlay>
with SingleTickerProviderStateMixin { with SingleTickerProviderStateMixin {
late Offset _dragPosition; late Offset _dragPosition;
late Size _handleSize; late Size _handleSize;
late AnimationController _controller; late AnimationController _controller;
@ -329,13 +328,12 @@ class _TextSelectionHandleOverlayState
} }
void _handleDragStart(DragStartDetails details) { void _handleDragStart(DragStartDetails details) {
_dragPosition = details.globalPosition + Offset(0.0, -_handleSize.height); _dragPosition = details.globalPosition + Offset(0, -_handleSize.height);
} }
void _handleDragUpdate(DragUpdateDetails details) { void _handleDragUpdate(DragUpdateDetails details) {
_dragPosition += details.delta; _dragPosition += details.delta;
final position = final position = widget.renderObject!.getPositionForOffset(_dragPosition);
widget.renderObject!.getPositionForOffset(_dragPosition);
if (widget.selection.isCollapsed) { if (widget.selection.isCollapsed) {
widget.onSelectionHandleChanged(TextSelection.fromPosition(position)); widget.onSelectionHandleChanged(TextSelection.fromPosition(position));
return; return;

Loading…
Cancel
Save