From 0478cbec600b3619b0080ca297e8d3c7660d6946 Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Mon, 1 Mar 2021 08:31:56 -0800 Subject: [PATCH] Removed RadioListTile accentColor dependency (#76906) --- .../lib/src/material/radio_list_tile.dart | 14 ++++---- .../test/material/radio_list_tile_test.dart | 36 +++++++++++++++++++ 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/packages/flutter/lib/src/material/radio_list_tile.dart b/packages/flutter/lib/src/material/radio_list_tile.dart index 54b18a7506..b4ac57da73 100644 --- a/packages/flutter/lib/src/material/radio_list_tile.dart +++ b/packages/flutter/lib/src/material/radio_list_tile.dart @@ -26,11 +26,13 @@ import 'theme_data.dart'; /// those of the same name on [ListTile]. /// /// The [selected] property on this widget is similar to the [ListTile.selected] -/// property, but the color used is that described by [activeColor], if any, -/// defaulting to the accent color of the current [Theme]. No effort is made to -/// coordinate the [selected] state and the [checked] state; to have the list -/// tile appear selected when the radio button is the selected radio button, set -/// [selected] to true when [value] matches [groupValue]. +/// property. This tile's [activeColor] is used for the selected item's text color, or +/// the theme's [ThemeData.toggleableActiveColor] if [activeColor] is null. +/// +/// This widget does not coordinate the [selected] state and the +/// [checked] state; to have the list tile appear selected when the +/// radio button is the selected radio button, set [selected] to true +/// when [value] matches [groupValue]. /// /// The radio button is shown on the left by default in left-to-right languages /// (i.e. the leading edge). This can be changed using [controlAffinity]. The @@ -520,7 +522,7 @@ class RadioListTile extends StatelessWidget { } return MergeSemantics( child: ListTileTheme.merge( - selectedColor: activeColor ?? Theme.of(context).accentColor, + selectedColor: activeColor ?? Theme.of(context).toggleableActiveColor, child: ListTile( leading: leading, title: title, diff --git a/packages/flutter/test/material/radio_list_tile_test.dart b/packages/flutter/test/material/radio_list_tile_test.dart index 1b411a4c07..7dba7d35cd 100644 --- a/packages/flutter/test/material/radio_list_tile_test.dart +++ b/packages/flutter/test/material/radio_list_tile_test.dart @@ -707,4 +707,40 @@ void main() { expect(find.byType(Material), paints..path(color: selectedTileColor)); }); + + testWidgets('RadioListTile selected item text Color', (WidgetTester tester) async { + // Regression test for https://github.com/flutter/flutter/pull/76906 + + const Color activeColor = Color(0xff00ff00); + + Widget buildFrame({ Color? activeColor, Color? toggleableActiveColor }) { + return MaterialApp( + theme: ThemeData.light().copyWith( + toggleableActiveColor: toggleableActiveColor, + ), + home: Scaffold( + body: Center( + child: RadioListTile( + activeColor: activeColor, + selected: true, + title: const Text('title'), + value: false, + groupValue: true, + onChanged: (bool? newValue) { }, + ), + ), + ), + ); + } + + Color? textColor(String text) { + return tester.renderObject(find.text(text)).text.style?.color; + } + + await tester.pumpWidget(buildFrame(toggleableActiveColor: activeColor)); + expect(textColor('title'), activeColor); + + await tester.pumpWidget(buildFrame(activeColor: activeColor)); + expect(textColor('title'), activeColor); + }); }