From 4feefa3c9a2176ca7383246c4c01b36254fbec85 Mon Sep 17 00:00:00 2001 From: rami-a <2364772+rami-a@users.noreply.github.com> Date: Thu, 14 Mar 2019 10:21:03 -0400 Subject: [PATCH] [Material] Fix radio ink ripple to be centered (#28845) --- packages/flutter/lib/src/material/radio.dart | 2 +- .../flutter/test/material/radio_test.dart | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/radio.dart b/packages/flutter/lib/src/material/radio.dart index 90109cfa9c..a3077eb0f8 100644 --- a/packages/flutter/lib/src/material/radio.dart +++ b/packages/flutter/lib/src/material/radio.dart @@ -214,7 +214,7 @@ class _RenderRadio extends RenderToggleable { void paint(PaintingContext context, Offset offset) { final Canvas canvas = context.canvas; - paintRadialReaction(canvas, offset, const Offset(kRadialReactionRadius, kRadialReactionRadius)); + paintRadialReaction(canvas, offset, size.center(Offset.zero)); final Offset center = (offset & size).center; final Color radioColor = onChanged != null ? activeColor : inactiveColor; diff --git a/packages/flutter/test/material/radio_test.dart b/packages/flutter/test/material/radio_test.dart index efce00476b..0d34fcb763 100644 --- a/packages/flutter/test/material/radio_test.dart +++ b/packages/flutter/test/material/radio_test.dart @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:io' show Platform; import 'dart:ui'; import 'package:flutter/rendering.dart'; @@ -245,5 +246,40 @@ void main() { semantics.dispose(); SystemChannels.accessibility.setMockMessageHandler(null); }); + + testWidgets('Radio ink ripple is displayed correctly', (WidgetTester tester) async { + final Key painterKey = UniqueKey(); + const Key radioKey = Key('radio'); + + await tester.pumpWidget(MaterialApp( + theme: ThemeData(), + home: Scaffold( + body: RepaintBoundary( + key: painterKey, + child: Center( + child: Container( + width: 100, + height: 100, + color: Colors.white, + child: Radio( + key: radioKey, + value: 1, + groupValue: 1, + onChanged: (int value) {}, + ), + ) + ), + ), + ), + )); + + await tester.press(find.byKey(radioKey)); + await tester.pumpAndSettle(); + await expectLater( + find.byKey(painterKey), + matchesGoldenFile('radio.ink_ripple.png'), + skip: !Platform.isLinux, + ); + }); }