-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Description
TextField cursor is misplaced after one character is input if the TextField's textAlign value is TextAlign.end, TextAlign.right, or TextAlign.center.
This issue just serves to collect the existing issues that have already reported the cursor problem: #17960, #17625, #17945, #18472.
The source of the problem is the call in TextPainter.to_getOffsetFromUpstream() to ui.Paragraph.getBoxesForRange(0, 1). The value returned by getBoxesForRange() would be correct if the text was left/start aligned.
After an additional character is entered, the cursor ends up where it belongs and stays there.
import 'package:flutter/material.dart';
class AlignedTextField extends StatelessWidget{
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Center(
child: new SizedBox(
width: 200.0,
child: new TextField(textAlign: TextAlign.end), // or TextAlign.right, TextAlign.center
),
),
);
}
}
void main() {
runApp(new MaterialApp(home: new AlignedTextField()));
}
Metadata
Metadata
Assignees
Labels
No labels