Expose a color property to CloseButton (#49256)
This commit is contained in:
parent
bc5c46438a
commit
782f9cceac
@ -128,13 +128,20 @@ class BackButton extends StatelessWidget {
|
|||||||
/// * [IconButton], to create other material design icon buttons.
|
/// * [IconButton], to create other material design icon buttons.
|
||||||
class CloseButton extends StatelessWidget {
|
class CloseButton extends StatelessWidget {
|
||||||
/// Creates a Material Design close button.
|
/// 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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
assert(debugCheckHasMaterialLocalizations(context));
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
return IconButton(
|
return IconButton(
|
||||||
icon: const Icon(Icons.close),
|
icon: const Icon(Icons.close),
|
||||||
|
color: color,
|
||||||
tooltip: MaterialLocalizations.of(context).closeButtonTooltip,
|
tooltip: MaterialLocalizations.of(context).closeButtonTooltip,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.maybePop(context);
|
Navigator.maybePop(context);
|
||||||
|
@ -69,7 +69,6 @@ void main() {
|
|||||||
final Key iOSKey = UniqueKey();
|
final Key iOSKey = UniqueKey();
|
||||||
final Key androidKey = UniqueKey();
|
final Key androidKey = UniqueKey();
|
||||||
|
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
home: Column(
|
home: Column(
|
||||||
@ -92,6 +91,24 @@ void main() {
|
|||||||
expect(iOSIcon == androidIcon, false);
|
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 {
|
testWidgets('BackButton semantics', (WidgetTester tester) async {
|
||||||
final SemanticsHandle handle = tester.ensureSemantics();
|
final SemanticsHandle handle = tester.ensureSemantics();
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -123,4 +140,22 @@ void main() {
|
|||||||
));
|
));
|
||||||
handle.dispose();
|
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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user