TextAffinity disambiguates text position for soft wraps and bidirectional text boundaries. The affinity can be either upstream or downstream. Downstream is the default.
Soft wrap position
Given the string 0123456789
whose last character soft-wraps to the next line, you can choose the cursor position as follows. Both positions are at offset 9
:
Downstream
Upstream
Bidirectional text boundary
Given the string Hello????
where Hello
is LRT text and ????
is RTL text, you can choose the cursor position at the boundary between them as follows. Both positions are at offset 5
:
Downstream
Upstream
Going on
I write about this in more detail here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…