Commit d04ab2e0 authored by Hans Muller's avatar Hans Muller

BoxDecoration borders define padding

parent 9b7ee3b7
...@@ -110,7 +110,7 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> { ...@@ -110,7 +110,7 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> {
onTap: _handleOnTap, onTap: _handleOnTap,
left: config.left, left: config.left,
center: new DefaultTextStyle( center: new DefaultTextStyle(
style: Theme.of(context).text.body1.copyWith(color: _headerColor.evaluate(_easeInAnimation)), style: Theme.of(context).text.subhead.copyWith(color: _headerColor.evaluate(_easeInAnimation)),
child: config.center child: config.center
), ),
right: new RotationTransition( right: new RotationTransition(
...@@ -136,7 +136,7 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> { ...@@ -136,7 +136,7 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
_borderColor.end = theme.dividerColor; _borderColor.end = theme.dividerColor;
_headerColor _headerColor
..begin = theme.text.body1.color ..begin = theme.text.subhead.color
..end = theme.accentColor; ..end = theme.accentColor;
_iconColor _iconColor
..begin = theme.unselectedColor ..begin = theme.unselectedColor
......
...@@ -793,6 +793,9 @@ class BoxDecoration extends Decoration { ...@@ -793,6 +793,9 @@ class BoxDecoration extends Decoration {
/// The shape to fill the background color into and to cast as a shadow. /// The shape to fill the background color into and to cast as a shadow.
final BoxShape shape; final BoxShape shape;
/// The inset space occupied by the border.
EdgeDims get padding => border?.dimensions;
/// Returns a new box decoration that is scaled by the given factor. /// Returns a new box decoration that is scaled by the given factor.
BoxDecoration scale(double factor) { BoxDecoration scale(double factor) {
// TODO(abarth): Scale ALL the things. // TODO(abarth): Scale ALL the things.
......
...@@ -109,6 +109,7 @@ class ShaderMask extends OneChildRenderObjectWidget { ...@@ -109,6 +109,7 @@ class ShaderMask extends OneChildRenderObjectWidget {
} }
/// Paints a [Decoration] either before or after its child paints. /// Paints a [Decoration] either before or after its child paints.
/// Container insets its child by the widths of the borders, this Widget does not.
/// ///
/// Commonly used with [BoxDecoration]. /// Commonly used with [BoxDecoration].
class DecoratedBox extends OneChildRenderObjectWidget { class DecoratedBox extends OneChildRenderObjectWidget {
......
...@@ -22,4 +22,23 @@ void main() { ...@@ -22,4 +22,23 @@ void main() {
); );
}); });
}); });
test('Bordered Container insets its child', () {
testWidgets((WidgetTester tester) {
Key key = new Key('outerContainer');
tester.pumpWidget(
new Center(
child: new Container(
key: key,
decoration: new BoxDecoration(border: new Border.all(width: 10.0)),
child: new Container(
width: 25.0,
height: 25.0
)
)
)
);
expect(tester.getSize(tester.findElementByKey(key)), equals(const Size(45.0, 45.0)));
});
});
} }
...@@ -49,8 +49,9 @@ void main() { ...@@ -49,8 +49,9 @@ void main() {
expect(getY(topKey), lessThan(getY(sublistKey))); expect(getY(topKey), lessThan(getY(sublistKey)));
expect(getY(sublistKey), lessThan(getY(bottomKey))); expect(getY(sublistKey), lessThan(getY(bottomKey)));
expect(getHeight(topKey), equals(getHeight(sublistKey))); // The sublist has a one pixel border above and below.
expect(getHeight(sublistKey), equals(getHeight(bottomKey))); expect(getHeight(topKey), equals(getHeight(sublistKey) - 2.0));
expect(getHeight(bottomKey), equals(getHeight(sublistKey) - 2.0));
tester.tap(tester.findText('Sublist')); tester.tap(tester.findText('Sublist'));
tester.pump(const Duration(seconds: 1)); tester.pump(const Duration(seconds: 1));
......
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