forked from firka/flutter
Fix DrawerHeader decoration not inheriting ColorScheme.primary (#101280)
This commit is contained in:
@@ -369,9 +369,7 @@ class _UserAccountsDrawerHeaderState extends State<UserAccountsDrawerHeader> {
|
||||
container: true,
|
||||
label: MaterialLocalizations.of(context).signedInLabel,
|
||||
child: DrawerHeader(
|
||||
decoration: widget.decoration ?? BoxDecoration(
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
decoration: widget.decoration ?? BoxDecoration(color: Theme.of(context).colorScheme.primary),
|
||||
margin: widget.margin,
|
||||
padding: const EdgeInsetsDirectional.only(top: 16.0, start: 16.0),
|
||||
child: SafeArea(
|
||||
|
||||
@@ -19,9 +19,15 @@ Future<void> pumpTestWidget(
|
||||
bool withOnDetailsPressedHandler = true,
|
||||
Size otherAccountsPictureSize = const Size.square(40.0),
|
||||
Size currentAccountPictureSize = const Size.square(72.0),
|
||||
Color? primaryColor,
|
||||
Color? colorSchemePrimary,
|
||||
}) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(
|
||||
primaryColor: primaryColor,
|
||||
colorScheme: const ColorScheme.light().copyWith(primary: colorSchemePrimary),
|
||||
),
|
||||
home: MediaQuery(
|
||||
data: const MediaQueryData(
|
||||
padding: EdgeInsets.only(
|
||||
@@ -76,6 +82,19 @@ void main() {
|
||||
matching: find.byType(Transform),
|
||||
);
|
||||
|
||||
testWidgets('UserAccountsDrawerHeader inherits ColorScheme.primary', (WidgetTester tester) async {
|
||||
const Color primaryColor = Color(0xff00ff00);
|
||||
const Color colorSchemePrimary = Color(0xff0000ff);
|
||||
|
||||
await pumpTestWidget(tester, primaryColor: primaryColor, colorSchemePrimary: colorSchemePrimary);
|
||||
|
||||
final BoxDecoration? boxDecoration = tester.widget<DrawerHeader>(
|
||||
find.byType(DrawerHeader),
|
||||
).decoration as BoxDecoration?;
|
||||
expect(boxDecoration?.color == primaryColor, false);
|
||||
expect(boxDecoration?.color == colorSchemePrimary, true);
|
||||
});
|
||||
|
||||
testWidgets('UserAccountsDrawerHeader test', (WidgetTester tester) async {
|
||||
await pumpTestWidget(tester);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user