Unverified Commit 9f4e132f authored by Haruka Ma's avatar Haruka Ma Committed by GitHub

Fix CupertinoTextField incorrect background color when disabled (#78058)

parent c3d0f604
......@@ -1137,7 +1137,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
final BoxDecoration? effectiveDecoration = widget.decoration?.copyWith(
border: resolvedBorder,
color: enabled ? decorationColor : (decorationColor ?? disabledColor),
color: enabled ? decorationColor : disabledColor,
);
final Color selectionColor = CupertinoTheme.of(context).primaryColor.withOpacity(0.2);
......
......@@ -4617,4 +4617,82 @@ void main() {
expect(state.currentTextEditingValue.composing, TextRange.empty);
});
});
testWidgets('disabled widget changes background color',
(WidgetTester tester) async {
await tester.pumpWidget(
const CupertinoApp(
home: Center(
child: CupertinoTextField(
enabled: false,
),
),
),
);
BoxDecoration decoration = tester
.widget<DecoratedBox>(
find.descendant(
of: find.byType(CupertinoTextField),
matching: find.byType(DecoratedBox),
),
)
.decoration as BoxDecoration;
expect(
decoration.color!.value,
0xFFFAFAFA,
);
await tester.pumpWidget(
const CupertinoApp(
home: Center(
child: CupertinoTextField(
enabled: true,
),
),
),
);
decoration = tester
.widget<DecoratedBox>(
find.descendant(
of: find.byType(CupertinoTextField),
matching: find.byType(DecoratedBox),
),
)
.decoration as BoxDecoration;
expect(
decoration.color!.value,
CupertinoColors.white.value,
);
await tester.pumpWidget(
const CupertinoApp(
theme: CupertinoThemeData(
brightness: Brightness.dark,
),
home: Center(
child: CupertinoTextField(
enabled: false,
),
),
),
);
decoration = tester
.widget<DecoratedBox>(
find.descendant(
of: find.byType(CupertinoTextField),
matching: find.byType(DecoratedBox),
),
)
.decoration as BoxDecoration;
expect(
decoration.color!.value,
0xFF050505,
);
});
}
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