Commit 34933f80 authored by Tran Huy Phuc's avatar Tran Huy Phuc Committed by Hans Muller

TextFormField/TextField - remove spaces in character counter (#18096)

* TextFormField/TextField - remove spaces in character counter(follow material design guidelines)
parent 609b9968
...@@ -317,7 +317,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi ...@@ -317,7 +317,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
if (!needsCounter) if (!needsCounter)
return effectiveDecoration; 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) { if (_effectiveController.value.text.runes.length > widget.maxLength) {
final ThemeData themeData = Theme.of(context); final ThemeData themeData = Theme.of(context);
return effectiveDecoration.copyWith( return effectiveDecoration.copyWith(
......
...@@ -1620,16 +1620,16 @@ void main() { ...@@ -1620,16 +1620,16 @@ void main() {
await tester.pump(); await tester.pump();
expect(textController.text, '0123456789101112'); expect(textController.text, '0123456789101112');
expect(find.text('16 / 10'), findsOneWidget); expect(find.text('16/10'), findsOneWidget);
Text counterTextWidget = tester.widget(find.text('16 / 10')); Text counterTextWidget = tester.widget(find.text('16/10'));
expect(counterTextWidget.style.color, equals(Colors.deepPurpleAccent)); expect(counterTextWidget.style.color, equals(Colors.deepPurpleAccent));
await tester.enterText(find.byType(TextField), '0123456789'); await tester.enterText(find.byType(TextField), '0123456789');
await tester.pump(); await tester.pump();
expect(textController.text, '0123456789'); expect(textController.text, '0123456789');
expect(find.text('10 / 10'), findsOneWidget); expect(find.text('10/10'), findsOneWidget);
counterTextWidget = tester.widget(find.text('10 / 10')); counterTextWidget = tester.widget(find.text('10/10'));
expect(counterTextWidget.style.color, isNot(equals(Colors.deepPurpleAccent))); expect(counterTextWidget.style.color, isNot(equals(Colors.deepPurpleAccent)));
}); });
...@@ -1647,12 +1647,12 @@ void main() { ...@@ -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.enterText(find.byType(TextField), '01234');
await tester.pump(); 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 { testWidgets('TextField identifies as text field in semantics', (WidgetTester tester) async {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment