diff --git a/packages/flutter/lib/src/material/outline_button.dart b/packages/flutter/lib/src/material/outline_button.dart index ba8158751b..2d7fcf0e78 100644 --- a/packages/flutter/lib/src/material/outline_button.dart +++ b/packages/flutter/lib/src/material/outline_button.dart @@ -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(), diff --git a/packages/flutter/test/material/outline_button_test.dart b/packages/flutter/test/material/outline_button_test.dart index cd1aecb406..ea40ce2392 100644 --- a/packages/flutter/test/material/outline_button_test.dart +++ b/packages/flutter/test/material/outline_button_test.dart @@ -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(