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
This commit is contained in:
Adam Barth 2016-03-24 13:36:07 -07:00
parent 7711b1f660
commit c8c325d095
8 changed files with 39 additions and 32 deletions

View file

@ -78,7 +78,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> {
return new Container(
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 Center(
child: new Text(page.label, style: textStyle)

View file

@ -72,7 +72,7 @@ class StockRow extends StatelessWidget {
onDoubleTap: _getHandler(onDoubleTap),
onLongPress: _getHandler(onLongPressed),
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(
border: new Border(
bottom: new BorderSide(color: Theme.of(context).dividerColor)

View file

@ -33,7 +33,7 @@ const double kFadingEdgeLength = 12.0;
const double kPressedStateDuration = 64.0; // units?
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 Duration kRadialReactionDuration = const Duration(milliseconds: 200);

View file

@ -62,7 +62,7 @@ class Dialog extends StatelessWidget {
if (title != null) {
EdgeInsets padding = titlePadding;
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(
padding: padding,
child: new DefaultTextStyle(
@ -75,7 +75,7 @@ class Dialog extends StatelessWidget {
if (content != null) {
EdgeInsets padding = contentPadding;
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(
padding: padding,
child: new DefaultTextStyle(

View file

@ -112,7 +112,7 @@ class Border {
/// The widths of the sides of this border represented as an EdgeInsets.
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.

View file

@ -12,8 +12,15 @@ import 'basic_types.dart';
/// example, the padding inside a box can be represented using this class.
class EdgeInsets {
/// 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);
/// 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.
const EdgeInsets.all(double value)
: top = value, right = value, bottom = value, left = value;
@ -56,63 +63,63 @@ class EdgeInsets {
Size get collapsedSize => new Size(horizontal, vertical);
/// 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) {
return new Rect.fromLTRB(rect.left - left, rect.top - top, rect.right + right, rect.bottom + bottom);
}
EdgeInsets operator -(EdgeInsets other) {
return new EdgeInsets.TRBL(
return new EdgeInsets.fromLTRB(
left - other.left,
top - other.top,
right - other.right,
bottom - other.bottom,
left - other.left
bottom - other.bottom
);
}
EdgeInsets operator +(EdgeInsets other) {
return new EdgeInsets.TRBL(
return new EdgeInsets.fromLTRB(
left + other.left,
top + other.top,
right + other.right,
bottom + other.bottom,
left + other.left
bottom + other.bottom
);
}
EdgeInsets operator *(double other) {
return new EdgeInsets.TRBL(
return new EdgeInsets.fromLTRB(
left * other,
top * other,
right * other,
bottom * other,
left * other
bottom * other
);
}
EdgeInsets operator /(double other) {
return new EdgeInsets.TRBL(
return new EdgeInsets.fromLTRB(
left / other,
top / other,
right / other,
bottom / other,
left / other
bottom / other
);
}
EdgeInsets operator ~/(double other) {
return new EdgeInsets.TRBL(
return new EdgeInsets.fromLTRB(
(left ~/ other).toDouble(),
(top ~/ other).toDouble(),
(right ~/ other).toDouble(),
(bottom ~/ other).toDouble(),
(left ~/ other).toDouble()
(bottom ~/ other).toDouble()
);
}
EdgeInsets operator %(double other) {
return new EdgeInsets.TRBL(
return new EdgeInsets.fromLTRB(
left % other,
top % other,
right % other,
bottom % other,
left % other
bottom % other
);
}
@ -126,16 +133,16 @@ class EdgeInsets {
return b * t;
if (b == null)
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.right, b.right, t),
ui.lerpDouble(a.bottom, b.bottom, t),
ui.lerpDouble(a.left, b.left, t)
ui.lerpDouble(a.bottom, b.bottom, t)
);
}
/// 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
bool operator ==(dynamic other) {

View file

@ -105,7 +105,7 @@ class WidgetsApp extends StatefulWidget {
}
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 {

View file

@ -100,7 +100,7 @@ void main() {
new ScrollableList(
key: new GlobalKey(),
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) {
return new Container(
child: new GestureDetector(
@ -135,7 +135,7 @@ void main() {
key: new GlobalKey(),
itemExtent: 290.0,
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) {
return new Container(
child: new GestureDetector(