Unverified Commit 64029ba6 authored by jslavitz's avatar jslavitz Committed by GitHub

Vertical divider (#22641)

* Vertical divider bug fix and additional cleaning.
parent 4a13be41
......@@ -170,49 +170,17 @@ class VerticalDivider extends StatelessWidget {
/// ```
final Color color;
/// Computes the [BorderSide] that represents a divider of the specified
/// color, or, if there is no specified color, of the default
/// [ThemeData.dividerColor] specified in the ambient [Theme].
///
/// The `width` argument can be used to override the default width of the
/// divider border, which is usually 0.0 (a hairline border).
///
/// ## Sample code
///
/// This example uses this method to create a box that has a divider above and
/// below it. This is sometimes useful with lists, for instance, to separate a
/// scrollable section from the rest of the interface.
///
/// ```dart
/// DecoratedBox(
/// decoration: BoxDecoration(
/// border: Border(
/// top: Divider.createBorderSide(context),
/// bottom: Divider.createBorderSide(context),
/// ),
/// ),
/// // child: ...
/// )
/// ```
static BorderSide createBorderSide(BuildContext context, { Color color, double width = 0.0 }) {
assert(width != null);
return BorderSide(
color: color ?? Theme.of(context).dividerColor,
width: width,
);
}
@override
Widget build(BuildContext context) {
return SizedBox(
width: width,
child: Center(
child: Container(
height: 0.0,
width: 0.0,
margin: EdgeInsetsDirectional.only(start: indent),
decoration: BoxDecoration(
border: Border(
left: createBorderSide(context, color: color),
left: Divider.createBorderSide(context, color: color),
),
),
),
......
......@@ -35,4 +35,28 @@ void main() {
expect(box.size.width, 16.0);
expect(find.byType(VerticalDivider), paints..path(strokeWidth: 0.0));
});
testWidgets('Vertical Divider Test 2', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
child: Container(
height: 24.0,
child: Row(
children: const <Widget>[
Text('Hey.'),
VerticalDivider(),
],
),
),
),
),
);
final RenderBox box = tester.firstRenderObject(find.byType(VerticalDivider));
final RenderBox containerBox = tester.firstRenderObject(find.byType(Container).last);
expect(box.size.width, 16.0);
expect(containerBox.size.height, 600.0);
expect(find.byType(VerticalDivider), paints..path(strokeWidth: 0.0));
});
}
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