Removed CheckboxListTile accentColor dependency (#76908)
This commit is contained in:
parent
0478cbec60
commit
b91b1644d9
@ -26,9 +26,10 @@ import 'theme_data.dart';
|
|||||||
/// those of the same name on [ListTile].
|
/// those of the same name on [ListTile].
|
||||||
///
|
///
|
||||||
/// The [selected] property on this widget is similar to the [ListTile.selected]
|
/// The [selected] property on this widget is similar to the [ListTile.selected]
|
||||||
/// property, but the color used is that described by [activeColor], if any,
|
/// property. This tile's [activeColor] is used for the selected item's text color, or
|
||||||
/// defaulting to the accent color of the current [Theme]. No effort is made to
|
/// the theme's [ThemeData.toggleableActiveColor] if [activeColor] is null.
|
||||||
/// coordinate the [selected] state and the [value] state; to have the list tile
|
///
|
||||||
|
/// This widget does not coordinate the [selected] state and the [value] state; to have the list tile
|
||||||
/// appear selected when the checkbox is checked, pass the same value to both.
|
/// appear selected when the checkbox is checked, pass the same value to both.
|
||||||
///
|
///
|
||||||
/// The checkbox is shown on the right by default in left-to-right languages
|
/// The checkbox is shown on the right by default in left-to-right languages
|
||||||
@ -432,7 +433,7 @@ class CheckboxListTile extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
return MergeSemantics(
|
return MergeSemantics(
|
||||||
child: ListTileTheme.merge(
|
child: ListTileTheme.merge(
|
||||||
selectedColor: activeColor ?? Theme.of(context).accentColor,
|
selectedColor: activeColor ?? Theme.of(context).toggleableActiveColor,
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: leading,
|
leading: leading,
|
||||||
title: title,
|
title: title,
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
|
|
||||||
import '../rendering/mock_canvas.dart';
|
import '../rendering/mock_canvas.dart';
|
||||||
|
|
||||||
@ -283,4 +284,39 @@ void main() {
|
|||||||
|
|
||||||
expect(find.byType(Material), paints..path(color: selectedTileColor));
|
expect(find.byType(Material), paints..path(color: selectedTileColor));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('CheckboxListTile selected item text Color', (WidgetTester tester) async {
|
||||||
|
// Regression test for https://github.com/flutter/flutter/pull/76908
|
||||||
|
|
||||||
|
const Color activeColor = Color(0xff00ff00);
|
||||||
|
|
||||||
|
Widget buildFrame({ Color? activeColor, Color? toggleableActiveColor }) {
|
||||||
|
return MaterialApp(
|
||||||
|
theme: ThemeData.light().copyWith(
|
||||||
|
toggleableActiveColor: toggleableActiveColor,
|
||||||
|
),
|
||||||
|
home: Scaffold(
|
||||||
|
body: Center(
|
||||||
|
child: CheckboxListTile(
|
||||||
|
activeColor: activeColor,
|
||||||
|
selected: true,
|
||||||
|
title: const Text('title'),
|
||||||
|
value: true,
|
||||||
|
onChanged: (bool? value) { },
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color? textColor(String text) {
|
||||||
|
return tester.renderObject<RenderParagraph>(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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user