Unverified Commit dde12499 authored by Ayush Bherwani's avatar Ayush Bherwani Committed by GitHub

[MergeableMaterial] adds dividerColor property (#59481)

parent b429ec1e
......@@ -107,6 +107,7 @@ class MergeableMaterial extends StatefulWidget {
this.elevation = 2,
this.hasDividers = false,
this.children = const <MergeableMaterialItem>[],
this.dividerColor,
}) : super(key: key);
/// The children of the [MergeableMaterial].
......@@ -128,6 +129,12 @@ class MergeableMaterial extends StatefulWidget {
/// Whether connected pieces of [MaterialSlice] have dividers between them.
final bool hasDividers;
/// Defines color used for dividers if [hasDividers] is true.
///
/// If `dividerColor` is null, then [DividerThemeData.color] is used. If that
/// is null, then [ThemeData.dividerColor] is used.
final Color dividerColor;
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
......@@ -562,6 +569,7 @@ class _MergeableMaterialState extends State<MergeableMaterial> with TickerProvid
final BorderSide divider = Divider.createBorderSide(
context,
width: 0.5, // TODO(ianh): This probably looks terrible when the dpr isn't a power of two.
color: widget.dividerColor,
);
if (i == 0) {
......
......@@ -1166,4 +1166,41 @@ void main() {
expect(isDivider(boxes[offset + 3], false, true), isTrue);
expect(isDivider(boxes[offset + 4], true, false), isTrue);
});
testWidgets('MergeableMaterial respects dividerColor', (WidgetTester tester) async {
const Color dividerColor = Colors.red;
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: SingleChildScrollView(
child: MergeableMaterial(
hasDividers: true,
dividerColor: dividerColor,
children: <MergeableMaterialItem>[
MaterialSlice(
key: ValueKey<String>('A'),
child: SizedBox(
width: 100.0,
height: 100.0,
),
),
MaterialSlice(
key: ValueKey<String>('B'),
child: SizedBox(
width: 100.0,
height: 100.0,
),
),
],
),
),
),
),
);
final DecoratedBox decoratedBox = tester.widget(find.byType(DecoratedBox).last);
final BoxDecoration decoration = decoratedBox.decoration as BoxDecoration;
// Since we are getting the last DecoratedBox, it will have a Border.top.
expect(decoration.border.top.color, dividerColor);
});
}
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