CupertinoTextField to show disabled background color when decoration is null (#78140)

This commit is contained in:
LongCatIsLooong 2021-03-15 14:18:03 -07:00 committed by GitHub
parent 5e84b1c343
commit 4f569fb326
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View file

@ -1216,6 +1216,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
ignoring: !enabled,
child: Container(
decoration: effectiveDecoration,
color: !enabled && effectiveDecoration == null ? disabledColor : null,
child: _selectionGestureDetectorBuilder.buildGestureDetector(
behavior: HitTestBehavior.translucent,
child: Align(

View file

@ -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<ColoredBox>(
find.descendant(
of: find.byType(CupertinoTextField),
matching: find.byType(ColoredBox),
),
).color;
expect(disabledColor, isSameColorAs(const Color(0xFFFAFAFA)));
});
}