Skip to content
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
3 changes: 2 additions & 1 deletion packages/fleather/lib/src/rendering/editable_text_line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,8 @@ class RenderEditableTextLine extends RenderEditableBox {
double computeDistanceToActualBaseline(TextBaseline baseline) {
_resolvePadding();
// The baseline of this widget is the baseline of the body.
return body!.getDistanceToActualBaseline(baseline)! + _resolvedPadding!.top;
return body!.getDistanceToActualBaseline(baseline) ??
0.0 + _resolvedPadding!.top;
}

@override
Expand Down
15 changes: 0 additions & 15 deletions packages/fleather/lib/src/widgets/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1627,21 +1627,6 @@ class RawEditorState extends EditorState
bool _showCaretOnScreenScheduled = false;

void _showCaretOnScreen([bool withAnimation = true]) {
assert(
widget.enableInteractiveSelection
? _scrollController.positions.isNotEmpty
: true,
'ScrollController not attached to any scroll views. '
'When editor configured with scrollable = false and '
'enableInteractiveSelection = true, make sure the editor is the child '
'of a Scrollable widget.');
assert(
widget.showCursor ? _scrollController.positions.isNotEmpty : true,
'ScrollController not attached to any scroll views. '
'When editor configured with scrollable = false and '
'showCursor = true, make sure the editor is the child '
'of a Scrollable widget.');

if (!widget.showCursor ||
!widget.enableInteractiveSelection ||
_showCaretOnScreenScheduled) {
Expand Down
20 changes: 19 additions & 1 deletion packages/fleather/test/widgets/editor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,7 @@ void main() {
});
});

group('field', () {
group('Field', () {
testWidgets('creating field without focusNode does not throw _CastError',
(tester) async {
final widget = MaterialApp(
Expand All @@ -1611,6 +1611,24 @@ void main() {
// Fails if thrown
});

testWidgets('handle insertion embeds with no baseline', (tester) async {
final controller = FleatherController();
final widget = MaterialApp(
home: FleatherField(
controller: controller,
),
);
await tester.pumpWidget(widget);
await tester.tap(find.byType(FleatherField));
await tester.pump();
controller.replaceText(0, 0, BlockEmbed.horizontalRule,
selection: TextSelection.collapsed(offset: 1));
await tester.pump(throttleDuration);
controller.replaceText(0, 0, BlockEmbed.horizontalRule,
selection: TextSelection.collapsed(offset: 1));
await tester.pump(throttleDuration);
});

testWidgets('shows cursor on screen with scroll parent', (tester) async {
final scrollController = ScrollController();
final controller = FleatherController();
Expand Down