From 64029ba6eace21764c5fc191e6344627abcb8aef Mon Sep 17 00:00:00 2001 From: jslavitz Date: Thu, 4 Oct 2018 10:29:32 -0700 Subject: [PATCH] Vertical divider (#22641) * Vertical divider bug fix and additional cleaning. --- .../flutter/lib/src/material/divider.dart | 36 ++----------------- .../flutter/test/material/divider_test.dart | 24 +++++++++++++ 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/packages/flutter/lib/src/material/divider.dart b/packages/flutter/lib/src/material/divider.dart index 5f5635a67ac..62a52aedec3 100644 --- a/packages/flutter/lib/src/material/divider.dart +++ b/packages/flutter/lib/src/material/divider.dart @@ -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), ), ), ), diff --git a/packages/flutter/test/material/divider_test.dart b/packages/flutter/test/material/divider_test.dart index 1b19fc77029..6a7ae902206 100644 --- a/packages/flutter/test/material/divider_test.dart +++ b/packages/flutter/test/material/divider_test.dart @@ -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 [ + 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)); + }); }