Unverified Commit a9ea085b authored by Gabe Moothart's avatar Gabe Moothart Committed by GitHub

Wire up autofocus for OutlineButton (#56494)

* Wireup autofocus for OutlineButton

Fixes #56493

* add test
parent d9882263
......@@ -175,6 +175,7 @@ class OutlineButton extends MaterialButton {
Widget build(BuildContext context) {
final ButtonThemeData buttonTheme = ButtonTheme.of(context);
return _OutlineButton(
autofocus: autofocus,
onPressed: onPressed,
onLongPress: onLongPress,
brightness: buttonTheme.getBrightness(this),
......@@ -450,6 +451,7 @@ class _OutlineButtonState extends State<_OutlineButton> with SingleTickerProvide
animation: _controller,
builder: (BuildContext context, Widget child) {
return RaisedButton(
autofocus: widget.autofocus,
textColor: widget.textColor,
disabledTextColor: widget.disabledTextColor,
color: _getFillColor(),
......
......@@ -133,6 +133,30 @@ void main() {
expect(inkFeatures, paints..rect(color: focusColor));
});
testWidgets('Does OutlineButton work with autofocus', (WidgetTester tester) async {
const Color focusColor = Color(0xff001122);
final FocusNode focusNode = FocusNode(debugLabel: 'OutlineButton Node');
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: OutlineButton(
autofocus: true,
focusColor: focusColor,
focusNode: focusNode,
onPressed: () { },
child: const Text('button'),
),
),
);
FocusManager.instance.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
await tester.pumpAndSettle();
final RenderObject inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures');
expect(inkFeatures, paints..rect(color: focusColor));
});
testWidgets('OutlineButton implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
OutlineButton(
......
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