Skip to content

cursor position error after dynamic insert #6

Closed
@li-xiaoyin

Description

@li-xiaoyin

My requirement is when user tap enter then auto insert two space. and my code as follows.
when I auto insert space, I expect cursor appear after space but now it appear before space
May be my code is wrong. please give me some suggestion Thank you.

I wish you can provide more examples.

@OverRide
void initState() {
this._controller.addListener(() {
this._controller.changes.first.then((value) {
if (value.item2.length >= 2 &&
value.item2[1].isInsert &&
value.item2[1].data == "\n") {
final index = this._controller.selection.baseOffset;
this._controller.document.insert(index, "  ");
}
});
});
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions