@@ -7618,6 +7618,85 @@ void main() {
76187618 });
76197619 });
76207620
7621+ group('Material3 - InputDecoration isDense', () {
7622+ // M3 extra horizontal padding.
7623+ const double kInputExtraPadding = 4.0;
7624+
7625+ testWidgets('Dense layout for an outlined decoration', (WidgetTester tester) async {
7626+ await tester.pumpWidget(
7627+ buildInputDecorator(
7628+ decoration: const InputDecoration(
7629+ border: OutlineInputBorder(),
7630+ labelText: labelText,
7631+ isDense: true,
7632+ ),
7633+ ),
7634+ );
7635+
7636+ final Rect containerRect = getContainerRect(tester);
7637+ final Rect inputRect = getInputRect(tester);
7638+
7639+ // Content padding is EdgeInsetsDirectional.fromSTEB(12.0, 16.0, 12.0, 8.0).
7640+ // Vertical padding affects the container height not the input vertical
7641+ // position as the input is centered.
7642+ expect(containerRect.height, 48.0);
7643+ expect(inputRect.center.dy, containerRect.center.dy);
7644+ expect(inputRect.left, containerRect.left + 12.0 + kInputExtraPadding);
7645+ expect(inputRect.right, containerRect.right - 12.0 - kInputExtraPadding);
7646+ });
7647+
7648+ testWidgets('Dense layout for a filled and non-outlined decoration', (
7649+ WidgetTester tester,
7650+ ) async {
7651+ await tester.pumpWidget(
7652+ buildInputDecorator(
7653+ decoration: const InputDecoration(filled: true, labelText: labelText, isDense: true),
7654+ ),
7655+ );
7656+
7657+ final Rect containerRect = getContainerRect(tester);
7658+ final Rect inputRect = getInputRect(tester);
7659+ final Rect labelRect = getLabelRect(tester);
7660+
7661+ // Content padding is EdgeInsetsDirectional.fromSTEB(12.0, 4.0, 12.0, 4.0).
7662+ expect(containerRect.height, 48.0);
7663+ expect(labelRect.top, containerRect.top + 4.0);
7664+ expect(inputRect.bottom, containerRect.bottom - 4.0);
7665+ expect(inputRect.left, containerRect.left + 12.0 + kInputExtraPadding);
7666+ expect(inputRect.right, containerRect.right - 12.0 - kInputExtraPadding);
7667+ });
7668+
7669+ testWidgets('Dense layout for a non-filled and non-outlined decoration', (
7670+ WidgetTester tester,
7671+ ) async {
7672+ await tester.pumpWidget(
7673+ buildInputDecorator(decoration: const InputDecoration(labelText: labelText, isDense: true)),
7674+ );
7675+
7676+ final Rect containerRect = getContainerRect(tester);
7677+ final Rect inputRect = getInputRect(tester);
7678+ final Rect labelRect = getLabelRect(tester);
7679+
7680+ // Content padding is EdgeInsetsDirectional.fromSTEB(0.0, 4.0, 0.0, 4.0).
7681+ expect(containerRect.height, 48.0);
7682+ expect(labelRect.top, containerRect.top + 4.0);
7683+ expect(inputRect.bottom, containerRect.bottom - 4.0);
7684+ expect(inputRect.left, containerRect.left);
7685+ expect(inputRect.right, containerRect.right);
7686+ });
7687+
7688+ testWidgets('Ambient theme is used', (WidgetTester tester) async {
7689+ await tester.pumpWidget(
7690+ buildInputDecorator(
7691+ inputDecorationTheme: const InputDecorationThemeData(isDense: true),
7692+ decoration: const InputDecoration(labelText: labelText),
7693+ ),
7694+ );
7695+
7696+ expect(getContainerRect(tester).height, 48.0);
7697+ });
7698+ });
7699+
76217700 testWidgets('InputDecorator counter text, widget, and null', (WidgetTester tester) async {
76227701 Widget buildFrame({
76237702 InputCounterWidgetBuilder? buildCounter,
@@ -9311,6 +9390,17 @@ void main() {
93119390 expect(getDecoratorRect(tester).size, const Size(800.0, inputHeight));
93129391 });
93139392
9393+ testWidgets('isDense', (WidgetTester tester) async {
9394+ await tester.pumpWidget(
9395+ buildInputDecorator(
9396+ localInputDecorationTheme: const InputDecorationThemeData(isDense: true),
9397+ decoration: const InputDecoration(labelText: labelText),
9398+ ),
9399+ );
9400+
9401+ expect(getContainerRect(tester).height, 48.0);
9402+ });
9403+
93149404 testWidgets('iconColor', (WidgetTester tester) async {
93159405 const Color iconColor = Colors.indigo;
93169406 await tester.pumpWidget(
0 commit comments