diff --git a/packages/flutter/lib/src/material/user_accounts_drawer_header.dart b/packages/flutter/lib/src/material/user_accounts_drawer_header.dart index b387fde4bc..c7f4a17cb1 100644 --- a/packages/flutter/lib/src/material/user_accounts_drawer_header.dart +++ b/packages/flutter/lib/src/material/user_accounts_drawer_header.dart @@ -369,9 +369,7 @@ class _UserAccountsDrawerHeaderState extends State { 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( diff --git a/packages/flutter/test/material/user_accounts_drawer_header_test.dart b/packages/flutter/test/material/user_accounts_drawer_header_test.dart index 3ff35a392d..08efb09f05 100644 --- a/packages/flutter/test/material/user_accounts_drawer_header_test.dart +++ b/packages/flutter/test/material/user_accounts_drawer_header_test.dart @@ -19,9 +19,15 @@ Future 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( + 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);