Fix #141061: Add 'color' property to DrawerButton and EndDrawerButton (#141159)

## Description

This PR addresses issue #141061, which requested the addition of a 'color' property to buttons extending _ActionButton. The 'color' property has been introduced to enhance customization options for these buttons.

## Issues Fixed

- Fixes #141061
This commit is contained in:
Sulav Parajuli 2024-01-16 15:53:27 +05:45 committed by GitHub
parent b45cd23173
commit a9f9136633
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 0 deletions

View File

@ -337,6 +337,7 @@ class DrawerButton extends _ActionButton {
/// Creates a Material Design drawer icon button.
const DrawerButton({
super.key,
super.color,
super.style,
super.onPressed,
}) : super(icon: const DrawerButtonIcon());
@ -402,6 +403,7 @@ class EndDrawerButton extends _ActionButton {
/// Creates a Material Design end drawer icon button.
const EndDrawerButton({
super.key,
super.color,
super.style,
super.onPressed,
}) : super(icon: const EndDrawerButtonIcon());

View File

@ -112,6 +112,24 @@ void main() {
});
testWidgets('DrawerButton color', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Material(
child: DrawerButton(
color: Colors.red,
),
),
),
);
final RichText iconText = tester.firstWidget(find.descendant(
of: find.byType(DrawerButton),
matching: find.byType(RichText),
));
expect(iconText.text.style!.color, Colors.red);
});
testWidgets('DrawerButton color with ButtonStyle', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: true),
@ -227,6 +245,24 @@ void main() {
}, variant: TargetPlatformVariant.all());
testWidgets('EndDrawerButton color', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Material(
child: EndDrawerButton(
color: Colors.red,
),
),
),
);
final RichText iconText = tester.firstWidget(find.descendant(
of: find.byType(EndDrawerButton),
matching: find.byType(RichText),
));
expect(iconText.text.style!.color, Colors.red);
});
testWidgets('EndDrawerButton color with ButtonStyle', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: true),