Commit 782f9cce authored by Darren Austin's avatar Darren Austin Committed by Flutter GitHub Bot

Expose a color property to CloseButton (#49256)

parent bc5c4643
......@@ -128,13 +128,20 @@ class BackButton extends StatelessWidget {
/// * [IconButton], to create other material design icon buttons.
class CloseButton extends StatelessWidget {
/// Creates a Material Design close button.
const CloseButton({ Key key }) : super(key: key);
const CloseButton({ Key key, this.color }) : super(key: key);
/// The color to use for the icon.
///
/// Defaults to the [IconThemeData.color] specified in the ambient [IconTheme],
/// which usually matches the ambient [Theme]'s [ThemeData.iconTheme].
final Color color;
@override
Widget build(BuildContext context) {
assert(debugCheckHasMaterialLocalizations(context));
return IconButton(
icon: const Icon(Icons.close),
color: color,
tooltip: MaterialLocalizations.of(context).closeButtonTooltip,
onPressed: () {
Navigator.maybePop(context);
......
......@@ -69,7 +69,6 @@ void main() {
final Key iOSKey = UniqueKey();
final Key androidKey = UniqueKey();
await tester.pumpWidget(
MaterialApp(
home: Column(
......@@ -92,6 +91,24 @@ void main() {
expect(iOSIcon == androidIcon, false);
});
testWidgets('BackButton color', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Material(
child: BackButton(
color: Colors.blue,
),
),
),
);
final RichText iconText = tester.firstWidget(find.descendant(
of: find.byType(BackButton),
matching: find.byType(RichText)
));
expect(iconText.text.style.color, Colors.blue);
});
testWidgets('BackButton semantics', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
......@@ -123,4 +140,22 @@ void main() {
));
handle.dispose();
});
testWidgets('CloseButton color', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Material(
child: CloseButton(
color: Colors.red,
),
),
),
);
final RichText iconText = tester.firstWidget(find.descendant(
of: find.byType(CloseButton),
matching: find.byType(RichText)
));
expect(iconText.text.style.color, Colors.red);
});
}
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