Commit c8c325d0 authored by Adam Barth's avatar Adam Barth

Replace EdgeInsets.TRBL with EdgeInsets.fromLTRB

This matches the pattern from Rect. I've left EdgeInsets.TRBL marked as
deprecated to give clients a chance to update.

Fixes #2860
parent 7711b1f6
...@@ -78,7 +78,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> { ...@@ -78,7 +78,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> {
return new Container( return new Container(
key: new ValueKey<String>(page.label), key: new ValueKey<String>(page.label),
padding: const EdgeInsets.TRBL(48.0, 48.0, 96.0, 48.0), padding: const EdgeInsets.fromLTRB(48.0, 48.0, 48.0, 96.0),
child: new Card( child: new Card(
child: new Center( child: new Center(
child: new Text(page.label, style: textStyle) child: new Text(page.label, style: textStyle)
......
...@@ -72,7 +72,7 @@ class StockRow extends StatelessWidget { ...@@ -72,7 +72,7 @@ class StockRow extends StatelessWidget {
onDoubleTap: _getHandler(onDoubleTap), onDoubleTap: _getHandler(onDoubleTap),
onLongPress: _getHandler(onLongPressed), onLongPress: _getHandler(onLongPressed),
child: new Container( child: new Container(
padding: const EdgeInsets.TRBL(16.0, 16.0, 20.0, 16.0), padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 20.0),
decoration: new BoxDecoration( decoration: new BoxDecoration(
border: new Border( border: new Border(
bottom: new BorderSide(color: Theme.of(context).dividerColor) bottom: new BorderSide(color: Theme.of(context).dividerColor)
......
...@@ -33,7 +33,7 @@ const double kFadingEdgeLength = 12.0; ...@@ -33,7 +33,7 @@ const double kFadingEdgeLength = 12.0;
const double kPressedStateDuration = 64.0; // units? const double kPressedStateDuration = 64.0; // units?
const Duration kThemeChangeDuration = const Duration(milliseconds: 200); const Duration kThemeChangeDuration = const Duration(milliseconds: 200);
const EdgeInsets kDialogHeadingPadding = const EdgeInsets.TRBL(24.0, 24.0, 20.0, 24.0); const EdgeInsets kDialogHeadingPadding = const EdgeInsets.fromLTRB(24.0, 24.0, 24.0, 20.0);
const double kRadialReactionRadius = 24.0; // Pixels const double kRadialReactionRadius = 24.0; // Pixels
const Duration kRadialReactionDuration = const Duration(milliseconds: 200); const Duration kRadialReactionDuration = const Duration(milliseconds: 200);
......
...@@ -62,7 +62,7 @@ class Dialog extends StatelessWidget { ...@@ -62,7 +62,7 @@ class Dialog extends StatelessWidget {
if (title != null) { if (title != null) {
EdgeInsets padding = titlePadding; EdgeInsets padding = titlePadding;
if (padding == null) if (padding == null)
padding = new EdgeInsets.TRBL(24.0, 24.0, content == null ? 20.0 : 0.0, 24.0); padding = new EdgeInsets.fromLTRB(24.0, 24.0, 24.0, content == null ? 20.0 : 0.0);
dialogBody.add(new Padding( dialogBody.add(new Padding(
padding: padding, padding: padding,
child: new DefaultTextStyle( child: new DefaultTextStyle(
...@@ -75,7 +75,7 @@ class Dialog extends StatelessWidget { ...@@ -75,7 +75,7 @@ class Dialog extends StatelessWidget {
if (content != null) { if (content != null) {
EdgeInsets padding = contentPadding; EdgeInsets padding = contentPadding;
if (padding == null) if (padding == null)
padding = const EdgeInsets.TRBL(20.0, 24.0, 24.0, 24.0); padding = const EdgeInsets.fromLTRB(24.0, 20.0, 24.0, 24.0);
dialogBody.add(new Padding( dialogBody.add(new Padding(
padding: padding, padding: padding,
child: new DefaultTextStyle( child: new DefaultTextStyle(
......
...@@ -112,7 +112,7 @@ class Border { ...@@ -112,7 +112,7 @@ class Border {
/// The widths of the sides of this border represented as an EdgeInsets. /// The widths of the sides of this border represented as an EdgeInsets.
EdgeInsets get dimensions { EdgeInsets get dimensions {
return new EdgeInsets.TRBL(top.width, right.width, bottom.width, left.width); return new EdgeInsets.fromLTRB(left.width, top.width, right.width, bottom.width);
} }
/// Whether all four sides of the border are identical. /// Whether all four sides of the border are identical.
......
...@@ -12,8 +12,15 @@ import 'basic_types.dart'; ...@@ -12,8 +12,15 @@ import 'basic_types.dart';
/// example, the padding inside a box can be represented using this class. /// example, the padding inside a box can be represented using this class.
class EdgeInsets { class EdgeInsets {
/// Constructs insets from offsets from the top, right, bottom and left. /// Constructs insets from offsets from the top, right, bottom and left.
///
/// We'll be removing this function sometime soon. Please use
/// [EdgeInsets.fromLTRB] instead.
@Deprecated('soon. Use fromLTRB instead.')
const EdgeInsets.TRBL(this.top, this.right, this.bottom, this.left); const EdgeInsets.TRBL(this.top, this.right, this.bottom, this.left);
/// Constructs insets from offsets from the left, top, right, and bottom.
const EdgeInsets.fromLTRB(this.left, this.top, this.right, this.bottom);
/// Constructs insets where all the offsets are value. /// Constructs insets where all the offsets are value.
const EdgeInsets.all(double value) const EdgeInsets.all(double value)
: top = value, right = value, bottom = value, left = value; : top = value, right = value, bottom = value, left = value;
...@@ -56,63 +63,63 @@ class EdgeInsets { ...@@ -56,63 +63,63 @@ class EdgeInsets {
Size get collapsedSize => new Size(horizontal, vertical); Size get collapsedSize => new Size(horizontal, vertical);
/// An EdgeInsets with top and bottom as well as left and right flipped. /// An EdgeInsets with top and bottom as well as left and right flipped.
EdgeInsets get flipped => new EdgeInsets.TRBL(bottom, left, top, right); EdgeInsets get flipped => new EdgeInsets.fromLTRB(left, top, right, bottom);
Rect inflateRect(Rect rect) { Rect inflateRect(Rect rect) {
return new Rect.fromLTRB(rect.left - left, rect.top - top, rect.right + right, rect.bottom + bottom); return new Rect.fromLTRB(rect.left - left, rect.top - top, rect.right + right, rect.bottom + bottom);
} }
EdgeInsets operator -(EdgeInsets other) { EdgeInsets operator -(EdgeInsets other) {
return new EdgeInsets.TRBL( return new EdgeInsets.fromLTRB(
left - other.left,
top - other.top, top - other.top,
right - other.right, right - other.right,
bottom - other.bottom, bottom - other.bottom
left - other.left
); );
} }
EdgeInsets operator +(EdgeInsets other) { EdgeInsets operator +(EdgeInsets other) {
return new EdgeInsets.TRBL( return new EdgeInsets.fromLTRB(
left + other.left,
top + other.top, top + other.top,
right + other.right, right + other.right,
bottom + other.bottom, bottom + other.bottom
left + other.left
); );
} }
EdgeInsets operator *(double other) { EdgeInsets operator *(double other) {
return new EdgeInsets.TRBL( return new EdgeInsets.fromLTRB(
left * other,
top * other, top * other,
right * other, right * other,
bottom * other, bottom * other
left * other
); );
} }
EdgeInsets operator /(double other) { EdgeInsets operator /(double other) {
return new EdgeInsets.TRBL( return new EdgeInsets.fromLTRB(
left / other,
top / other, top / other,
right / other, right / other,
bottom / other, bottom / other
left / other
); );
} }
EdgeInsets operator ~/(double other) { EdgeInsets operator ~/(double other) {
return new EdgeInsets.TRBL( return new EdgeInsets.fromLTRB(
(left ~/ other).toDouble(),
(top ~/ other).toDouble(), (top ~/ other).toDouble(),
(right ~/ other).toDouble(), (right ~/ other).toDouble(),
(bottom ~/ other).toDouble(), (bottom ~/ other).toDouble()
(left ~/ other).toDouble()
); );
} }
EdgeInsets operator %(double other) { EdgeInsets operator %(double other) {
return new EdgeInsets.TRBL( return new EdgeInsets.fromLTRB(
left % other,
top % other, top % other,
right % other, right % other,
bottom % other, bottom % other
left % other
); );
} }
...@@ -126,16 +133,16 @@ class EdgeInsets { ...@@ -126,16 +133,16 @@ class EdgeInsets {
return b * t; return b * t;
if (b == null) if (b == null)
return a * (1.0 - t); return a * (1.0 - t);
return new EdgeInsets.TRBL( return new EdgeInsets.fromLTRB(
ui.lerpDouble(a.left, b.left, t),
ui.lerpDouble(a.top, b.top, t), ui.lerpDouble(a.top, b.top, t),
ui.lerpDouble(a.right, b.right, t), ui.lerpDouble(a.right, b.right, t),
ui.lerpDouble(a.bottom, b.bottom, t), ui.lerpDouble(a.bottom, b.bottom, t)
ui.lerpDouble(a.left, b.left, t)
); );
} }
/// An EdgeInsets with zero offsets in each direction. /// An EdgeInsets with zero offsets in each direction.
static const EdgeInsets zero = const EdgeInsets.TRBL(0.0, 0.0, 0.0, 0.0); static const EdgeInsets zero = const EdgeInsets.all(0.0);
@override @override
bool operator ==(dynamic other) { bool operator ==(dynamic other) {
......
...@@ -105,7 +105,7 @@ class WidgetsApp extends StatefulWidget { ...@@ -105,7 +105,7 @@ class WidgetsApp extends StatefulWidget {
} }
EdgeInsets _getPadding(ui.WindowPadding padding) { EdgeInsets _getPadding(ui.WindowPadding padding) {
return new EdgeInsets.TRBL(padding.top, padding.right, padding.bottom, padding.left); return new EdgeInsets.fromLTRB(padding.left, padding.top, padding.right, padding.bottom);
} }
class WidgetsAppState<T extends WidgetsApp> extends State<T> implements BindingObserver { class WidgetsAppState<T extends WidgetsApp> extends State<T> implements BindingObserver {
......
...@@ -100,7 +100,7 @@ void main() { ...@@ -100,7 +100,7 @@ void main() {
new ScrollableList( new ScrollableList(
key: new GlobalKey(), key: new GlobalKey(),
itemExtent: 290.0, itemExtent: 290.0,
padding: new EdgeInsets.TRBL(20.0, 15.0, 10.0, 5.0), padding: new EdgeInsets.fromLTRB(5.0, 20.0, 15.0, 10.0),
children: items.map((int item) { children: items.map((int item) {
return new Container( return new Container(
child: new GestureDetector( child: new GestureDetector(
...@@ -135,7 +135,7 @@ void main() { ...@@ -135,7 +135,7 @@ void main() {
key: new GlobalKey(), key: new GlobalKey(),
itemExtent: 290.0, itemExtent: 290.0,
scrollAnchor: ViewportAnchor.end, scrollAnchor: ViewportAnchor.end,
padding: new EdgeInsets.TRBL(20.0, 15.0, 10.0, 5.0), padding: new EdgeInsets.fromLTRB(5.0, 20.0, 15.0, 10.0),
children: items.map((int item) { children: items.map((int item) {
return new Container( return new Container(
child: new GestureDetector( child: new GestureDetector(
......
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