TextFormField/TextField - remove spaces in character counter (#18096)
* TextFormField/TextField - remove spaces in character counter(follow material design guidelines)
This commit is contained in:
committed by
Hans Muller
parent
609b996846
commit
34933f801f
@@ -317,7 +317,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
|
||||
if (!needsCounter)
|
||||
return effectiveDecoration;
|
||||
|
||||
final String counterText = '${_effectiveController.value.text.runes.length} / ${widget.maxLength}';
|
||||
final String counterText = '${_effectiveController.value.text.runes.length}/${widget.maxLength}';
|
||||
if (_effectiveController.value.text.runes.length > widget.maxLength) {
|
||||
final ThemeData themeData = Theme.of(context);
|
||||
return effectiveDecoration.copyWith(
|
||||
|
||||
@@ -1620,16 +1620,16 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
expect(textController.text, '0123456789101112');
|
||||
expect(find.text('16 / 10'), findsOneWidget);
|
||||
Text counterTextWidget = tester.widget(find.text('16 / 10'));
|
||||
expect(find.text('16/10'), findsOneWidget);
|
||||
Text counterTextWidget = tester.widget(find.text('16/10'));
|
||||
expect(counterTextWidget.style.color, equals(Colors.deepPurpleAccent));
|
||||
|
||||
await tester.enterText(find.byType(TextField), '0123456789');
|
||||
await tester.pump();
|
||||
|
||||
expect(textController.text, '0123456789');
|
||||
expect(find.text('10 / 10'), findsOneWidget);
|
||||
counterTextWidget = tester.widget(find.text('10 / 10'));
|
||||
expect(find.text('10/10'), findsOneWidget);
|
||||
counterTextWidget = tester.widget(find.text('10/10'));
|
||||
expect(counterTextWidget.style.color, isNot(equals(Colors.deepPurpleAccent)));
|
||||
});
|
||||
|
||||
@@ -1647,12 +1647,12 @@ void main() {
|
||||
),
|
||||
));
|
||||
|
||||
expect(find.text('0 / 10'), findsOneWidget);
|
||||
expect(find.text('0/10'), findsOneWidget);
|
||||
|
||||
await tester.enterText(find.byType(TextField), '01234');
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('5 / 10'), findsOneWidget);
|
||||
expect(find.text('5/10'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('TextField identifies as text field in semantics', (WidgetTester tester) async {
|
||||
|
||||
Reference in New Issue
Block a user