Request keyboard focus when no child is found

`getRenderEditor()!.selectWordEdge` and
`getRenderEditor().selectPosition` currently throw a `'No child'` which
prevents the field from focusing. This happens when `minHeight` is set
and the whole field is not filled with content from the editor (e. g.
it's empty or only one line has some data).

This change catches the `'No child'` exception and lets the code to
continue its execution and request field focus.
pull/531/head
f-person 4 years ago
parent a0f3830ad5
commit aed4311579
  1. 14
      lib/src/widgets/editor.dart

@ -599,16 +599,22 @@ class _QuillEditorSelectionGestureDetectorBuilder
break;
case PointerDeviceKind.touch:
case PointerDeviceKind.unknown:
getRenderEditor()!.selectWordEdge(SelectionChangedCause.tap);
break;
try {
getRenderEditor()!.selectWordEdge(SelectionChangedCause.tap);
} finally {
break;
}
}
break;
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
getRenderEditor()!.selectPosition(SelectionChangedCause.tap);
break;
try {
getRenderEditor()!.selectPosition(SelectionChangedCause.tap);
} finally {
break;
}
}
}
_state._requestKeyboard();

Loading…
Cancel
Save