diff --git a/packages/flutter/lib/src/cupertino/text_field.dart b/packages/flutter/lib/src/cupertino/text_field.dart index 473b3b18f0..c3af40acfd 100644 --- a/packages/flutter/lib/src/cupertino/text_field.dart +++ b/packages/flutter/lib/src/cupertino/text_field.dart @@ -1216,6 +1216,7 @@ class _CupertinoTextFieldState extends State with Restoratio ignoring: !enabled, child: Container( decoration: effectiveDecoration, + color: !enabled && effectiveDecoration == null ? disabledColor : null, child: _selectionGestureDetectorBuilder.buildGestureDetector( behavior: HitTestBehavior.translucent, child: Align( diff --git a/packages/flutter/test/cupertino/text_field_test.dart b/packages/flutter/test/cupertino/text_field_test.dart index 07f5920dc4..017841a83a 100644 --- a/packages/flutter/test/cupertino/text_field_test.dart +++ b/packages/flutter/test/cupertino/text_field_test.dart @@ -4695,4 +4695,28 @@ void main() { 0xFF050505, ); }); + + // Regression test for https://github.com/flutter/flutter/issues/78097. + testWidgets( + 'still gets disabled background color when decoration is null', + (WidgetTester tester) async { + await tester.pumpWidget( + const CupertinoApp( + home: Center( + child: CupertinoTextField( + decoration: null, + enabled: false, + ), + ), + ), + ); + + final Color disabledColor = tester.widget( + find.descendant( + of: find.byType(CupertinoTextField), + matching: find.byType(ColoredBox), + ), + ).color; + expect(disabledColor, isSameColorAs(const Color(0xFFFAFAFA))); + }); }