Unverified Commit a77388e6 authored by Hans Muller's avatar Hans Muller Committed by GitHub

ToggleButtons focus,highlight,hoverElevation = 0 (#75454)

parent da6528cd
......@@ -910,12 +910,13 @@ class _ToggleButton extends StatelessWidget {
),
constraints: currentConstraints,
elevation: 0.0,
highlightElevation: 0.0,
fillColor: currentFillColor,
focusColor: currentFocusColor,
highlightColor: highlightColor
?? theme.colorScheme.surface.withOpacity(0.0),
focusElevation: 0,
highlightColor: highlightColor ?? theme.colorScheme.surface.withOpacity(0.0),
highlightElevation: 0.0,
hoverColor: currentHoverColor,
hoverElevation: 0,
splashColor: currentSplashColor,
focusNode: focusNode,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
......
......@@ -1649,4 +1649,52 @@ void main() {
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
});
testWidgets('ToggleButtons focus, hover, and highlight elevations are 0', (WidgetTester tester) async {
final List<FocusNode> focusNodes = <FocusNode>[FocusNode(), FocusNode()];
await tester.pumpWidget(
Material(
child: boilerplate(
child: ToggleButtons(
isSelected: const <bool>[true, false],
onPressed: (int index) { },
focusNodes: focusNodes,
children: const <Widget>[Text('one'), Text('two')],
),
),
),
);
double toggleButtonElevation(String text) {
return tester.widget<Material>(find.widgetWithText(Material, text).first).elevation;
}
// Default toggle button elevation
expect(toggleButtonElevation('one'), 0); // highlighted
expect(toggleButtonElevation('two'), 0); // not highlighted
// Hovered button elevation
final TestGesture hoverGesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await hoverGesture.addPointer();
await hoverGesture.moveTo(tester.getCenter(find.text('one')));
await tester.pumpAndSettle();
expect(toggleButtonElevation('one'), 0);
await hoverGesture.moveTo(tester.getCenter(find.text('two')));
await tester.pumpAndSettle();
expect(toggleButtonElevation('two'), 0);
// Focused button elevation
focusNodes[0].requestFocus();
await tester.pumpAndSettle();
expect(focusNodes[0].hasFocus, isTrue);
expect(focusNodes[1].hasFocus, isFalse);
expect(toggleButtonElevation('one'), 0);
focusNodes[1].requestFocus();
await tester.pumpAndSettle();
expect(focusNodes[0].hasFocus, isFalse);
expect(focusNodes[1].hasFocus, isTrue);
expect(toggleButtonElevation('two'), 0);
await hoverGesture.removePointer();
});
}
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