@@ -6463,6 +6463,120 @@ void main() {
6463
6463
});
6464
6464
});
6465
6465
6466
+ group('Material3 - InputDecoration collapsed', () {
6467
+ // Overall height for a collapsed InputDecorator is 24dp which is the input
6468
+ // height (font size = 16, line height = 1.5).
6469
+ const double inputHeight = 24.0;
6470
+
6471
+ testWidgets('Decoration height is set to input height on mobile', (WidgetTester tester) async {
6472
+ await tester.pumpWidget(
6473
+ buildInputDecorator(
6474
+ decoration: const InputDecoration.collapsed(
6475
+ hintText: hintText,
6476
+ ),
6477
+ ),
6478
+ );
6479
+
6480
+ expect(getDecoratorRect(tester).size, const Size(800.0, inputHeight));
6481
+ expect(getInputRect(tester).height, inputHeight);
6482
+ expect(getInputRect(tester).top, 0.0);
6483
+ expect(getHintOpacity(tester), 0.0);
6484
+
6485
+ // The hint should appear.
6486
+ await tester.pumpWidget(
6487
+ buildInputDecorator(
6488
+ isEmpty: true,
6489
+ isFocused: true,
6490
+ decoration: const InputDecoration.collapsed(
6491
+ hintText: hintText,
6492
+ ),
6493
+ ),
6494
+ );
6495
+ await tester.pumpAndSettle();
6496
+
6497
+ expect(getDecoratorRect(tester).size, const Size(800.0, inputHeight));
6498
+ expect(getInputRect(tester).height, inputHeight);
6499
+ expect(getInputRect(tester).top, 0.0);
6500
+ expect(getHintOpacity(tester), 1.0);
6501
+ expect(getHintRect(tester).height, inputHeight);
6502
+ expect(getHintRect(tester).top, 0.0);
6503
+ }, variant: TargetPlatformVariant.mobile());
6504
+
6505
+ testWidgets('Decoration height is set to input height on desktop', (WidgetTester tester) async {
6506
+ // Regression test for https://github.com/flutter/flutter/issues/150763.
6507
+ await tester.pumpWidget(
6508
+ buildInputDecorator(
6509
+ decoration: const InputDecoration.collapsed(
6510
+ hintText: hintText,
6511
+ ),
6512
+ ),
6513
+ );
6514
+
6515
+ expect(getDecoratorRect(tester).size, const Size(800.0, inputHeight));
6516
+ expect(getInputRect(tester).height, inputHeight);
6517
+ expect(getInputRect(tester).top, 0.0);
6518
+ expect(getHintOpacity(tester), 0.0);
6519
+
6520
+ // The hint should appear.
6521
+ await tester.pumpWidget(
6522
+ buildInputDecorator(
6523
+ isEmpty: true,
6524
+ isFocused: true,
6525
+ decoration: const InputDecoration.collapsed(
6526
+ hintText: hintText,
6527
+ ),
6528
+ ),
6529
+ );
6530
+ await tester.pumpAndSettle();
6531
+
6532
+ expect(getDecoratorRect(tester).size, const Size(800.0, inputHeight));
6533
+ expect(getInputRect(tester).height, inputHeight);
6534
+ expect(getInputRect(tester).top, 0.0);
6535
+ expect(getHintOpacity(tester), 1.0);
6536
+ expect(getHintRect(tester).height, inputHeight);
6537
+ expect(getHintRect(tester).top, 0.0);
6538
+ }, variant: TargetPlatformVariant.desktop());
6539
+
6540
+ testWidgets('InputDecoration.collapsed defaults to no border', (WidgetTester tester) async {
6541
+ await tester.pumpWidget(
6542
+ buildInputDecorator(
6543
+ decoration: const InputDecoration.collapsed(
6544
+ hintText: hintText,
6545
+ ),
6546
+ ),
6547
+ );
6548
+
6549
+ expect(getBorderWeight(tester), 0.0);
6550
+ });
6551
+
6552
+ test('InputDecorationTheme.isCollapsed is applied', () {
6553
+ final InputDecoration decoration = const InputDecoration(
6554
+ hintText: 'Hello, Flutter!',
6555
+ ).applyDefaults(const InputDecorationTheme(
6556
+ isCollapsed: true,
6557
+ ));
6558
+
6559
+ expect(decoration.isCollapsed, true);
6560
+ });
6561
+
6562
+ test('InputDecorationTheme.isCollapsed defaults to false', () {
6563
+ final InputDecoration decoration = const InputDecoration(
6564
+ hintText: 'Hello, Flutter!',
6565
+ ).applyDefaults(const InputDecorationTheme());
6566
+
6567
+ expect(decoration.isCollapsed, false);
6568
+ });
6569
+
6570
+ test('InputDecorationTheme.isCollapsed can be overriden', () {
6571
+ final InputDecoration decoration = const InputDecoration(
6572
+ isCollapsed: true,
6573
+ hintText: 'Hello, Flutter!',
6574
+ ).applyDefaults(const InputDecorationTheme());
6575
+
6576
+ expect(decoration.isCollapsed, true);
6577
+ });
6578
+ });
6579
+
6466
6580
testWidgets('InputDecorator counter text, widget, and null', (WidgetTester tester) async {
6467
6581
Widget buildFrame({
6468
6582
InputCounterWidgetBuilder? buildCounter,
@@ -7482,27 +7596,6 @@ void main() {
7482
7596
expect(tester.takeException(), isNull);
7483
7597
});
7484
7598
7485
- group('isCollapsed parameter works with themeData', () {
7486
- test('parameter is provided in InputDecorationTheme', () {
7487
- final InputDecoration decoration = const InputDecoration(
7488
- hintText: 'Hello, Flutter!',
7489
- ).applyDefaults(const InputDecorationTheme(
7490
- isCollapsed: true,
7491
- ));
7492
-
7493
- expect(decoration.isCollapsed, true);
7494
- });
7495
-
7496
- test('parameter is provided in InputDecoration', () {
7497
- final InputDecoration decoration = const InputDecoration(
7498
- isCollapsed: true,
7499
- hintText: 'Hello, Flutter!',
7500
- ).applyDefaults(const InputDecorationTheme());
7501
-
7502
- expect(decoration.isCollapsed, true);
7503
- });
7504
- });
7505
-
7506
7599
testWidgets('Ensure the height of labelStyle remains unchanged when TextField is focused', (WidgetTester tester) async {
7507
7600
// Regression test for https://github.com/flutter/flutter/issues/141448.
7508
7601
final FocusNode focusNode = FocusNode();
0 commit comments