Commit 2b126bcd authored by Adam Barth's avatar Adam Barth Committed by GitHub

Add Alignment, which will replace FractionalOffset (#12342)

Unlike FractionalOffset, Alignment uses the center as the zero of the
coordinate system, which makes the RTL math work out much cleaner.

Also, make FractionalOffset into a subclass of Alignment so that clients
can continue to use FractionalOffset.
parent 89566fee
......@@ -17,6 +17,7 @@
/// painting boxes.
library painting;
export 'src/painting/alignment.dart';
export 'src/painting/basic_types.dart';
export 'src/painting/border_radius.dart';
export 'src/painting/borders.dart';
......
......@@ -416,7 +416,7 @@ class _CupertinoLargeTitleNavigationBarSliverDelegate extends SliverPersistentHe
child: new OverflowBox(
minHeight: 0.0,
maxHeight: double.INFINITY,
alignment: FractionalOffsetDirectional.bottomStart,
alignment: AlignmentDirectional.bottomStart,
child: new Padding(
padding: const EdgeInsetsDirectional.only(
start: _kNavBarEdgePadding,
......
......@@ -11,21 +11,21 @@ const double _kBackGestureWidth = 20.0;
const double _kMinFlingVelocity = 1.0; // Screen widths per second.
// Fractional offset from offscreen to the right to fully on screen.
final FractionalOffsetTween _kRightMiddleTween = new FractionalOffsetTween(
begin: FractionalOffset.topRight,
end: FractionalOffset.topLeft,
final AlignmentTween _kRightMiddleTween = new AlignmentTween(
begin: Alignment.centerRight * 2.0,
end: Alignment.center,
);
// Fractional offset from fully on screen to 1/3 offscreen to the left.
final FractionalOffsetTween _kMiddleLeftTween = new FractionalOffsetTween(
begin: FractionalOffset.topLeft,
end: const FractionalOffset(-1.0/3.0, 0.0),
final AlignmentTween _kMiddleLeftTween = new AlignmentTween(
begin: Alignment.center,
end: const Alignment(-2.0/3.0, 0.0),
);
// Fractional offset from offscreen below to fully on screen.
final FractionalOffsetTween _kBottomUpTween = new FractionalOffsetTween(
begin: FractionalOffset.bottomLeft,
end: FractionalOffset.topLeft,
final AlignmentTween _kBottomUpTween = new AlignmentTween(
begin: Alignment.bottomCenter * 2.0,
end: Alignment.center,
);
// Custom decoration from no shadow to page shadow mimicking iOS page
......@@ -35,8 +35,8 @@ final DecorationTween _kGradientShadowTween = new DecorationTween(
end: const _CupertinoEdgeShadowDecoration(
edgeGradient: const LinearGradient(
// Spans 5% of the page.
begin: const FractionalOffset(0.95, 0.0),
end: FractionalOffset.topRight,
begin: const Alignment(0.90, 0.0),
end: Alignment.centerRight,
// Eyeballed gradient used to mimic a drop shadow on the left side only.
colors: const <Color>[
const Color(0x00000000),
......@@ -318,9 +318,9 @@ class CupertinoPageTransition extends StatelessWidget {
super(key: key);
// When this page is coming in to cover another page.
final Animation<FractionalOffset> _primaryPositionAnimation;
final Animation<Alignment> _primaryPositionAnimation;
// When this page is becoming covered by another page.
final Animation<FractionalOffset> _secondaryPositionAnimation;
final Animation<Alignment> _secondaryPositionAnimation;
final Animation<Decoration> _primaryShadowAnimation;
/// The widget below this widget in the tree.
......@@ -361,7 +361,7 @@ class CupertinoFullscreenDialogTransition extends StatelessWidget {
),
super(key: key);
final Animation<FractionalOffset> _positionAnimation;
final Animation<Alignment> _positionAnimation;
/// The widget below this widget in the tree.
final Widget child;
......@@ -562,7 +562,7 @@ class _CupertinoEdgeShadowDecoration extends Decoration {
const _CupertinoEdgeShadowDecoration();
/// A gradient to draw to the left of the box being decorated.
/// FractionalOffsets are relative to the original box translated one box
/// Alignments are relative to the original box translated one box
/// width to the left.
final LinearGradient edgeGradient;
......
......@@ -145,7 +145,7 @@ class _CupertinoTabScaffoldState extends State<CupertinoTabScaffold> {
if (widget.tabBar != null) {
stacked.add(new Align(
alignment: FractionalOffset.bottomCenter,
alignment: Alignment.bottomCenter,
// Override the tab bar's currentIndex to the current tab and hook in
// our own listener to update the _currentPage on top of a possibly user
// provided callback.
......
......@@ -448,7 +448,7 @@ class _AppBarState extends State<AppBar> {
}
appBar = new Align(
alignment: FractionalOffset.topCenter,
alignment: Alignment.topCenter,
child: appBar,
);
......
......@@ -215,14 +215,14 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
return (leftWeights + _flex(_animations[index]) / 2.0) / allWeights;
}
FractionalOffset _circleOffset(int index) {
Alignment _circleOffset(int index) {
final double iconSize = widget.iconSize;
final Tween<double> yOffsetTween = new Tween<double>(
begin: (18.0 + iconSize / 2.0) / kBottomNavigationBarHeight, // 18dp + icon center
end: (6.0 + iconSize / 2.0) / kBottomNavigationBarHeight // 6dp + icon center
);
return new FractionalOffset(
return new Alignment(
_xOffset(index),
yOffsetTween.evaluate(_animations[index])
);
......@@ -283,10 +283,10 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
widget.onTap(i);
},
child: new Stack(
alignment: FractionalOffset.center,
alignment: Alignment.center,
children: <Widget>[
new Align(
alignment: FractionalOffset.topCenter,
alignment: Alignment.topCenter,
child: new Container(
margin: new EdgeInsets.only(
top: new Tween<double>(
......@@ -304,7 +304,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
),
),
new Align(
alignment: FractionalOffset.bottomCenter,
alignment: Alignment.bottomCenter,
child: new Container(
margin: const EdgeInsets.only(bottom: 10.0),
child: DefaultTextStyle.merge(
......@@ -319,7 +319,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
end: 1.0,
).evaluate(_animations[i]),
)),
alignment: FractionalOffset.bottomCenter,
alignment: Alignment.bottomCenter,
child: widget.items[i].title,
),
),
......@@ -352,10 +352,10 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
widget.onTap(i);
},
child: new Stack(
alignment: FractionalOffset.center,
alignment: Alignment.center,
children: <Widget>[
new Align(
alignment: FractionalOffset.topCenter,
alignment: Alignment.topCenter,
child: new Container(
margin: new EdgeInsets.only(
top: new Tween<double>(
......@@ -373,7 +373,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
),
),
new Align(
alignment: FractionalOffset.bottomCenter,
alignment: Alignment.bottomCenter,
child: new Container(
margin: const EdgeInsets.only(bottom: 10.0),
child: new FadeTransition(
......@@ -465,7 +465,7 @@ class _Circle {
AnimationController controller;
CurvedAnimation animation;
FractionalOffset get offset {
Alignment get offset {
return state._circleOffset(index);
}
......@@ -487,11 +487,13 @@ class _RadialPainter extends CustomPainter {
// bounding rectangle's corners touches the egde of the circle. Drawing a
// circle beyond this radius is futile since there is no perceivable
// difference within the cropped rectangle.
double _maxRadius(FractionalOffset offset, Size size) {
final double dx = offset.dx;
final double dy = offset.dy;
final double x = (dx > 0.5 ? dx : 1.0 - dx) * size.width;
final double y = (dy > 0.5 ? dy : 1.0 - dy) * size.height;
double _maxRadius(Alignment alignment, Size size) {
final double dx = alignment.x;
final double dy = alignment.y;
final double halfWidth = size.width / 2.0;
final double halfHeight = size.height / 2.0;
final double x = halfWidth + dx.abs() * halfWidth;
final double y = halfHeight + dy.abs() * halfHeight;
return math.sqrt(x * x + y * y);
}
......@@ -517,20 +519,22 @@ class _RadialPainter extends CustomPainter {
for (_Circle circle in circles) {
final Tween<double> radiusTween = new Tween<double>(
begin: 0.0,
end: _maxRadius(circle.offset, size)
end: _maxRadius(circle.offset, size),
);
final Paint paint = new Paint()..color = circle.color;
final Rect rect = new Rect.fromLTWH(0.0, 0.0, size.width, size.height);
canvas.clipRect(rect);
final double navWidth = math.min(bottomNavMaxWidth, size.width);
final double halfNavWidth = navWidth / 2.0;
final double halfHeight = size.height / 2.0;
final Offset center = new Offset(
(size.width - navWidth) / 2.0 + circle.offset.dx * navWidth,
circle.offset.dy * size.height
(size.width - navWidth) / 2.0 + halfNavWidth + circle.offset.x * halfNavWidth,
halfHeight + circle.offset.y * halfHeight,
);
canvas.drawCircle(
center,
radiusTween.lerp(circle.animation.value),
paint
paint,
);
}
}
......
......@@ -408,7 +408,7 @@ class DataTable extends StatelessWidget {
label = new Container(
padding: padding,
height: _kHeadingRowHeight,
alignment: numeric ? FractionalOffset.centerRight : FractionalOffsetDirectional.centerStart,
alignment: numeric ? Alignment.centerRight : AlignmentDirectional.centerStart,
child: new AnimatedDefaultTextStyle(
style: new TextStyle(
// TODO(ianh): font family should be Roboto; see https://github.com/flutter/flutter/issues/3116
......@@ -460,7 +460,7 @@ class DataTable extends StatelessWidget {
label = new Container(
padding: padding,
height: _kDataRowHeight,
alignment: numeric ? FractionalOffset.centerRight : FractionalOffsetDirectional.centerStart,
alignment: numeric ? Alignment.centerRight : AlignmentDirectional.centerStart,
child: new DefaultTextStyle(
style: new TextStyle(
// TODO(ianh): font family should be Roboto; see https://github.com/flutter/flutter/issues/3116
......@@ -774,7 +774,7 @@ class _SortArrowState extends State<_SortArrow> with TickerProviderStateMixin {
child: new Transform(
transform: new Matrix4.rotationZ(_orientationOffset + _orientationAnimation.value)
..setTranslationRaw(0.0, _kArrowIconBaselineOffset, 0.0),
alignment: FractionalOffset.center,
alignment: Alignment.center,
child: new Icon(
Icons.arrow_downward,
size: _kArrowIconSize,
......
......@@ -267,7 +267,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
Widget _buildDrawer(BuildContext context) {
if (_controller.status == AnimationStatus.dismissed) {
return new Align(
alignment: FractionalOffsetDirectional.centerStart,
alignment: AlignmentDirectional.centerStart,
child: new GestureDetector(
key: _gestureDetectorKey,
onHorizontalDragUpdate: _move,
......@@ -299,9 +299,9 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
),
),
new Align(
alignment: FractionalOffsetDirectional.centerStart,
alignment: AlignmentDirectional.centerStart,
child: new Align(
alignment: FractionalOffsetDirectional.centerEnd,
alignment: AlignmentDirectional.centerEnd,
widthFactor: _controller.value,
child: new RepaintBoundary(
child: new FocusScope(
......
......@@ -361,7 +361,7 @@ class DropdownMenuItem<T> extends StatelessWidget {
Widget build(BuildContext context) {
return new Container(
height: _kMenuItemHeight,
alignment: FractionalOffset.centerLeft,
alignment: Alignment.centerLeft,
child: child,
);
}
......@@ -589,7 +589,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
// the hint or nothing at all.
new IndexedStack(
index: _selectedIndex ?? hintIndex,
alignment: FractionalOffset.centerLeft,
alignment: Alignment.centerLeft,
children: items,
),
new Icon(Icons.arrow_drop_down,
......
......@@ -92,16 +92,16 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
return null;
}
FractionalOffset _getTitleAlignment(bool effectiveCenterTitle) {
Alignment _getTitleAlignment(bool effectiveCenterTitle) {
if (effectiveCenterTitle)
return FractionalOffset.bottomCenter;
return Alignment.bottomCenter;
final TextDirection textDirection = Directionality.of(context);
assert(textDirection != null);
switch (textDirection) {
case TextDirection.rtl:
return FractionalOffset.bottomRight;
return Alignment.bottomRight;
case TextDirection.ltr:
return FractionalOffset.bottomLeft;
return Alignment.bottomLeft;
}
return null;
}
......@@ -152,7 +152,7 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
final double scaleValue = new Tween<double>(begin: 1.5, end: 1.0).lerp(t);
final Matrix4 scaleTransform = new Matrix4.identity()
..scale(scaleValue, scaleValue, 1.0);
final FractionalOffset titleAlignment = _getTitleAlignment(effectiveCenterTitle);
final Alignment titleAlignment = _getTitleAlignment(effectiveCenterTitle);
children.add(new Container(
padding: new EdgeInsetsDirectional.only(
start: effectiveCenterTitle ? 0.0 : 72.0,
......
......@@ -73,7 +73,7 @@ class IconButton extends StatelessWidget {
Key key,
this.iconSize: 24.0,
this.padding: const EdgeInsets.all(8.0),
this.alignment: FractionalOffset.center,
this.alignment: Alignment.center,
@required this.icon,
this.color,
this.highlightColor,
......@@ -107,8 +107,8 @@ class IconButton extends StatelessWidget {
/// Defines how the icon is positioned within the IconButton.
///
/// This property must not be null. It defaults to [FractionalOffset.center].
final FractionalOffsetGeometry alignment;
/// This property must not be null. It defaults to [Alignment.center].
final AlignmentGeometry alignment;
/// The icon to display inside the button.
///
......
......@@ -397,7 +397,7 @@ class ListTile extends StatelessWidget {
child: new Container(
margin: const EdgeInsetsDirectional.only(end: 16.0),
width: 40.0,
alignment: FractionalOffsetDirectional.centerStart,
alignment: AlignmentDirectional.centerStart,
child: leading,
),
));
......@@ -432,7 +432,7 @@ class ListTile extends StatelessWidget {
data: iconThemeData,
child: new Container(
margin: const EdgeInsetsDirectional.only(start: 16.0),
alignment: FractionalOffsetDirectional.centerEnd,
alignment: AlignmentDirectional.centerEnd,
child: trailing,
),
));
......
......@@ -9,9 +9,9 @@ import 'package:flutter/widgets.dart';
import 'theme.dart';
// Fractional offset from 1/4 screen below the top to fully on screen.
final FractionalOffsetTween _kBottomUpTween = new FractionalOffsetTween(
begin: FractionalOffset.bottomLeft,
end: FractionalOffset.topLeft
final AlignmentTween _kBottomUpTween = new AlignmentTween(
begin: Alignment.bottomCenter * 0.5,
end: Alignment.center
);
// Used for Android and Fuchsia.
......@@ -26,7 +26,7 @@ class _MountainViewPageTransition extends StatelessWidget {
)),
super(key: key);
final Animation<FractionalOffset> _positionAnimation;
final Animation<Alignment> _positionAnimation;
final Widget child;
@override
......
......@@ -447,7 +447,7 @@ class _PopupMenu<T> extends StatelessWidget {
type: MaterialType.card,
elevation: route.elevation,
child: new Align(
alignment: FractionalOffset.topRight,
alignment: Alignment.topRight,
widthFactor: width.evaluate(route.animation),
heightFactor: height.evaluate(route.animation),
child: child,
......
......@@ -384,15 +384,15 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
left: 0.0,
right: 0.0,
child: new SizeTransition(
axisAlignment: _isIndicatorAtTop ? 1.0 : 0.0,
axisAlignment: _isIndicatorAtTop ? 1.0 : -1.0,
sizeFactor: _positionFactor, // this is what brings it down
child: new Container(
padding: _isIndicatorAtTop
? new EdgeInsets.only(top: widget.displacement)
: new EdgeInsets.only(bottom: widget.displacement),
alignment: _isIndicatorAtTop
? FractionalOffset.topCenter
: FractionalOffset.bottomCenter,
? Alignment.topCenter
: Alignment.bottomCenter,
child: new ScaleTransition(
scale: _scaleFactor,
child: new AnimatedBuilder(
......
......@@ -898,7 +898,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
bottomSheets.add(_currentBottomSheet._widget);
final Widget stack = new Stack(
children: bottomSheets,
alignment: FractionalOffset.bottomCenter,
alignment: Alignment.bottomCenter,
);
_addIfNonNull(
children,
......@@ -1053,7 +1053,7 @@ class _PersistentBottomSheetState extends State<_PersistentBottomSheet> {
animation: widget.animationController,
builder: (BuildContext context, Widget child) {
return new Align(
alignment: FractionalOffsetDirectional.topStart,
alignment: AlignmentDirectional.topStart,
heightFactor: widget.animationController.value,
child: child
);
......
......@@ -82,7 +82,7 @@ class SnackBarAction extends StatefulWidget {
const SnackBarAction({
Key key,
@required this.label,
@required this.onPressed
@required this.onPressed,
}) : assert(label != null),
assert(onPressed != null),
super(key: key);
......@@ -117,7 +117,7 @@ class _SnackBarActionState extends State<SnackBarAction> {
Widget build(BuildContext context) {
return new FlatButton(
onPressed: _haveTriggeredAction ? null : _handlePressed,
child: new Text(widget.label)
child: new Text(widget.label),
);
}
}
......@@ -192,7 +192,7 @@ class SnackBar extends StatelessWidget {
final ThemeData darkTheme = new ThemeData(
brightness: Brightness.dark,
accentColor: theme.accentColor,
accentColorBrightness: theme.accentColorBrightness
accentColorBrightness: theme.accentColorBrightness,
);
final List<Widget> children = <Widget>[
const SizedBox(width: _kSnackBarPadding),
......@@ -202,15 +202,15 @@ class SnackBar extends StatelessWidget {
child: new DefaultTextStyle(
style: darkTheme.textTheme.subhead,
child: content,
)
)
)
),
),
),
];
if (action != null) {
children.add(new ButtonTheme.bar(
padding: const EdgeInsets.symmetric(horizontal: _kSnackBarPadding),
textTheme: ButtonTextTheme.accent,
child: action
child: action,
));
} else {
children.add(const SizedBox(width: _kSnackBarPadding));
......@@ -222,9 +222,9 @@ class SnackBar extends StatelessWidget {
animation: heightAnimation,
builder: (BuildContext context, Widget child) {
return new Align(
alignment: FractionalOffsetDirectional.topStart,
alignment: AlignmentDirectional.topStart,
heightFactor: heightAnimation.value,
child: child
child: child,
);
},
child: new Semantics(
......@@ -245,14 +245,14 @@ class SnackBar extends StatelessWidget {
opacity: fadeAnimation,
child: new Row(
children: children,
crossAxisAlignment: CrossAxisAlignment.center
)
)
)
)
)
)
)
crossAxisAlignment: CrossAxisAlignment.center,
),
),
),
),
),
),
),
);
}
......@@ -278,7 +278,7 @@ class SnackBar extends StatelessWidget {
backgroundColor: backgroundColor,
action: action,
duration: duration,
animation: newAnimation
animation: newAnimation,
);
}
}
......@@ -297,7 +297,7 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
color: _isDark() ? _kErrorDark : _kErrorLight,
),
child: new Align(
alignment: const FractionalOffset(0.5, 0.9), // 0.9 looks better than the geometrical 0.66.
alignment: const Alignment(0.0, 0.8), // 0.8 looks better than the geometrical 0.33.
child: _buildCircleChild(index, oldState && widget.steps[index].state != StepState.error),
),
),
......
......@@ -70,7 +70,7 @@ class _AccountDetails extends StatelessWidget {
Widget addDropdownIcon(Widget line) {
final Widget icon = new Expanded(
child: new Align(
alignment: FractionalOffsetDirectional.centerEnd,
alignment: AlignmentDirectional.centerEnd,
child: new Icon(
isOpen ? Icons.arrow_drop_up : Icons.arrow_drop_down,
color: Colors.white
......
This diff is collapsed.
......@@ -98,9 +98,9 @@ class FittedSizes {
/// This method does not express an opinion regarding the alignment of the
/// source and destination sizes within the input and output rectangles.
/// Typically they are centered (this is what [BoxDecoration] does, for
/// instance, and is how [BoxFit] is defined). The [FractionalOffset] class
/// provides a convenience function, [FractionalOffset.inscribe], for resolving
/// the sizes to rects, as shown in the example below.
/// instance, and is how [BoxFit] is defined). The [Alignment] class provides a
/// convenience function, [Alignment.inscribe], for resolving the sizes to
/// rects, as shown in the example below.
///
/// ## Sample code
///
......@@ -112,8 +112,8 @@ class FittedSizes {
/// void paintImage(ui.Image image, Rect outputRect, Canvas canvas, Paint paint, BoxFit fit) {
/// final Size imageSize = new Size(image.width.toDouble(), image.height.toDouble());
/// final FittedSizes sizes = applyBoxFit(fit, imageSize, outputRect.size);
/// final Rect inputSubrect = FractionalOffset.center.inscribe(sizes.source, Offset.zero & imageSize);
/// final Rect outputSubrect = FractionalOffset.center.inscribe(sizes.destination, outputRect);
/// final Rect inputSubrect = Alignment.center.inscribe(sizes.source, Offset.zero & imageSize);
/// final Rect outputSubrect = Alignment.center.inscribe(sizes.destination, outputRect);
/// canvas.drawImageRect(image, inputSubrect, outputSubrect, paint);
/// }
/// ```
......
......@@ -9,11 +9,11 @@ import 'dart:ui' as ui show Gradient, TextBox, lerpDouble;
import 'package:flutter/services.dart';
import 'package:flutter/foundation.dart';
import 'alignment.dart';
import 'basic_types.dart';
import 'box_fit.dart';
import 'decoration.dart';
import 'edge_insets.dart';
import 'fractional_offset.dart';
import 'text_painter.dart';
import 'text_span.dart';
import 'text_style.dart';
......@@ -397,7 +397,7 @@ class _FlutterLogoPainter extends BoxPainter {
}
final FittedSizes fittedSize = applyBoxFit(BoxFit.contain, logoSize, canvasSize);
assert(fittedSize.source == logoSize);
final Rect rect = FractionalOffset.center.inscribe(fittedSize.destination, offset & canvasSize);
final Rect rect = Alignment.center.inscribe(fittedSize.destination, offset & canvasSize);
final double centerSquareHeight = canvasSize.shortestSide;
final Rect centerSquare = new Rect.fromLTWH(
offset.dx + (canvasSize.width - centerSquareHeight) / 2.0,
......
......@@ -6,8 +6,8 @@ import 'dart:ui' as ui show Gradient, lerpDouble;
import 'package:flutter/foundation.dart';
import 'alignment.dart';
import 'basic_types.dart';
import 'fractional_offset.dart';
/// A 2D gradient.
///
......@@ -27,7 +27,7 @@ abstract class Gradient {
/// Creates a [Shader] for this gradient to fill the given rect.
///
/// If the gradient's configuration is text-direction-dependent, for example
/// it uses [FractionalOffsetDirectional] objects instead of [FractionalOffset]
/// it uses [AlignmentDirectional] objects instead of [Alignment]
/// objects, then the `textDirection` argument must not be null.
Shader createShader(Rect rect, { TextDirection textDirection });
}
......@@ -64,8 +64,8 @@ abstract class Gradient {
/// new Container(
/// decoration: new BoxDecoration(
/// gradient: new LinearGradient(
/// begin: FractionalOffset.topLeft,
/// end: new FractionalOffset(0.1, 0.0), // 10% of the width, so there are ten blinds.
/// begin: Alignment.topLeft,
/// end: new Alignment(0.8, 0.0), // 10% of the width, so there are ten blinds.
/// colors: [const Color(0xFFFFFFEE), const Color(0xFF999999)], // whitish to gray
/// tileMode: TileMode.repeated, // repeats the gradient over the canvas
/// ),
......@@ -85,8 +85,8 @@ class LinearGradient extends Gradient {
/// The [colors] argument must not be null. If [stops] is non-null, it must
/// have the same length as [colors].
const LinearGradient({
this.begin: FractionalOffset.centerLeft,
this.end: FractionalOffset.centerRight,
this.begin: Alignment.centerLeft,
this.end: Alignment.centerRight,
@required this.colors,
this.stops,
this.tileMode: TileMode.clamp,
......@@ -97,35 +97,33 @@ class LinearGradient extends Gradient {
/// The offset at which stop 0.0 of the gradient is placed.
///
/// If this is a [FractionalOffset], then it is expressed as a vector from
/// coordinate (0.0,0.0), in a coordinate space that maps the top left of the
/// paint box at (0.0,0.0) and the bottom right at (1.0,1.0).
/// If this is a [Alignment], then it is expressed as a vector from
/// coordinate (0.0, 0.0), in a coordinate space that maps the center of the
/// paint box at (0.0, 0.0) and the bottom right at (1.0, 1.0).
///
/// For example, a begin offset of (0.0,0.5) is half way down the
/// For example, a begin offset of (-1.0, 0.0) is half way down the
/// left side of the box.
///
/// It can also be a [FractionalOffsetDirectional], in which case it is
/// expressed as a vector from the top start corner, where the start is the
/// It can also be a [AlignmentDirectional], where the start is the
/// left in left-to-right contexts and the right in right-to-left contexts. If
/// a text-direction-dependent value is provided here, then the [createShader]
/// method will need to be given a [TextDirection].
final FractionalOffsetGeometry begin;
final AlignmentGeometry begin;
/// The offset at which stop 1.0 of the gradient is placed.
///
/// If this is a [FractionalOffset], then it is expressed as a vector from
/// coordinate (0.0,0.0), in a coordinate space that maps the top left of the
/// paint box at (0.0,0.0) and the bottom right at (1.0,1.0).
/// If this is a [Alignment], then it is expressed as a vector from
/// coordinate (0.0, 0.0), in a coordinate space that maps the center of the
/// paint box at (0.0, 0.0) and the bottom right at (1.0, 1.0).
///
/// For example, a begin offset of (1.0,0.5) is half way down the
/// For example, a begin offset of (1.0, 0.0) is half way down the
/// right side of the box.
///
/// It can also be a [FractionalOffsetDirectional], in which case it is
/// expressed as a vector from the top start corner, where the start is the
/// left in left-to-right contexts and the right in right-to-left contexts. If
/// a text-direction-dependent value is provided here, then the [createShader]
/// It can also be a [AlignmentDirectional], where the start is the left in
/// left-to-right contexts and the right in right-to-left contexts. If a
/// text-direction-dependent value is provided here, then the [createShader]
/// method will need to be given a [TextDirection].
final FractionalOffsetGeometry end;
final AlignmentGeometry end;
/// The colors the gradient should obtain at each of the stops.
///
......@@ -215,8 +213,8 @@ class LinearGradient extends Gradient {
interpolatedStops = a.stops ?? b.stops;
}
return new LinearGradient(
begin: FractionalOffsetGeometry.lerp(a.begin, b.begin, t),
end: FractionalOffsetGeometry.lerp(a.end, b.end, t),
begin: AlignmentGeometry.lerp(a.begin, b.begin, t),
end: AlignmentGeometry.lerp(a.end, b.end, t),
colors: interpolatedColors,
stops: interpolatedStops,
tileMode: t < 0.5 ? a.tileMode : b.tileMode,
......@@ -295,7 +293,7 @@ class LinearGradient extends Gradient {
/// ```dart
/// void paintSky(Canvas canvas, Rect rect) {
/// var gradient = new RadialGradient(
/// center: const FractionalOffset(0.7, 0.2), // near the top right
/// center: const Alignment(0.7, -0.6), // near the top right
/// radius: 0.2,
/// colors: [
/// const Color(0xFFFFFF00), // yellow sun
......@@ -324,7 +322,7 @@ class RadialGradient extends Gradient {
/// The [colors] argument must not be null. If [stops] is non-null, it must
/// have the same length as [colors].
const RadialGradient({
this.center: FractionalOffset.center,
this.center: Alignment.center,
this.radius: 0.5,
@required this.colors,
this.stops,
......@@ -334,22 +332,21 @@ class RadialGradient extends Gradient {
assert(colors != null),
assert(tileMode != null);
/// The center of the gradient, as an offset into the unit square
/// describing the gradient which will be mapped onto the paint box.
/// The center of the gradient, as an offset into the (-1.0, -1.0) x (1.0, 1.0)
/// square describing the gradient which will be mapped onto the paint box.
///
/// For example, an offset of (0.5,0.5) will place the radial
/// For example, an alignment of (0.0, 0.0) will place the radial
/// gradient in the center of the box.
///
/// If this is a [FractionalOffset], then it is expressed as a vector from
/// coordinate (0.0,0.0), in a coordinate space that maps the top left of the
/// paint box at (0.0,0.0) and the bottom right at (1.0,1.0).
/// If this is a [Alignment], then it is expressed as a vector from
/// coordinate (0.0, 0.0), in a coordinate space that maps the center of the
/// paint box at (0.0, 0.0) and the bottom right at (1.0, 1.0).
///
/// It can also be a [FractionalOffsetDirectional], in which case it is
/// expressed as a vector from the top start corner, where the start is the
/// left in left-to-right contexts and the right in right-to-left contexts. If
/// a text-direction-dependent value is provided here, then the [createShader]
/// It can also be a [AlignmentDirectional], where the start is the left in
/// left-to-right contexts and the right in right-to-left contexts. If a
/// text-direction-dependent value is provided here, then the [createShader]
/// method will need to be given a [TextDirection].
final FractionalOffsetGeometry center;
final AlignmentGeometry center;
/// The radius of the gradient, as a fraction of the shortest side
/// of the paint box.
......
......@@ -7,10 +7,10 @@ import 'dart:ui' as ui show Image;
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'alignment.dart';
import 'basic_types.dart';
import 'borders.dart';
import 'box_fit.dart';
import 'fractional_offset.dart';
/// How to paint any portions of a box not covered by an image.
enum ImageRepeat {
......@@ -41,7 +41,7 @@ class DecorationImage {
@required this.image,
this.colorFilter,
this.fit,
this.alignment: FractionalOffset.center,
this.alignment: Alignment.center,
this.centerSlice,
this.repeat: ImageRepeat.noRepeat,
this.matchTextDirection: false,
......@@ -70,22 +70,22 @@ class DecorationImage {
/// How to align the image within its bounds.
///
/// The alignment aligns the given position in the image to the given position
/// in the layout bounds. For example, a [FractionalOffset] alignment of (0.0,
/// 0.0) aligns the image to the top-left corner of its layout bounds, while a
/// [FractionalOffset] alignment of (1.0, 1.0) aligns the bottom right of the
/// in the layout bounds. For example, a [Alignment] alignment of (-1.0,
/// -1.0) aligns the image to the top-left corner of its layout bounds, while a
/// [Alignment] alignment of (1.0, 1.0) aligns the bottom right of the
/// image with the bottom right corner of its layout bounds. Similarly, an
/// alignment of (0.5, 1.0) aligns the bottom middle of the image with the
/// alignment of (0.0, 1.0) aligns the bottom middle of the image with the
/// middle of the bottom edge of its layout bounds.
///
/// To display a subpart of an image, consider using a [CustomPainter] and
/// [Canvas.drawImageRect].
///
/// If the [alignment] is [TextDirection]-dependent (i.e. if it is a
/// [FractionalOffsetDirectional]), then a [TextDirection] must be available
/// [AlignmentDirectional]), then a [TextDirection] must be available
/// when the image is painted.
///
/// Defaults to [FractionalOffset.center].
final FractionalOffsetGeometry alignment;
/// Defaults to [Alignment.center].
final AlignmentGeometry alignment;
/// The center slice for a nine-patch image.
///
......@@ -180,9 +180,9 @@ class DecorationImage {
///
/// * `alignment`: How the destination rectangle defined by applying `fit` is
/// aligned within `rect`. For example, if `fit` is [BoxFit.contain] and
/// `alignment` is [FractionalOffset.bottomRight], the image will be as large
/// `alignment` is [Alignment.bottomRight], the image will be as large
/// as possible within `rect` and placed with its bottom right corner at the
/// bottom right corner of `rect`. Defaults to [FractionalOffset.center].
/// bottom right corner of `rect`. Defaults to [Alignment.center].
///
/// * `centerSlice`: The image is drawn in nine portions described by splitting
/// the image by drawing two horizontal lines and two vertical lines, where
......@@ -219,7 +219,7 @@ void paintImage({
@required ui.Image image,
ColorFilter colorFilter,
BoxFit fit,
FractionalOffset alignment: FractionalOffset.center,
Alignment alignment: Alignment.center,
Rect centerSlice,
ImageRepeat repeat: ImageRepeat.noRepeat,
bool flipHorizontally: false,
......@@ -268,8 +268,10 @@ void paintImage({
// to nearest-neighbor.
paint.filterQuality = FilterQuality.low;
}
final double dx = (outputSize.width - destinationSize.width) * (flipHorizontally ? 1.0 - alignment.dx : alignment.dx);
final double dy = (outputSize.height - destinationSize.height) * alignment.dy;
final double halfWidthDelta = (outputSize.width - destinationSize.width) / 2.0;
final double halfHeightDelta = (outputSize.height - destinationSize.height) / 2.0;
final double dx = halfWidthDelta + (flipHorizontally ? -alignment.x : alignment.x) * halfWidthDelta;
final double dy = halfHeightDelta + alignment.y * halfHeightDelta;
final Offset destinationPosition = rect.topLeft.translate(dx, dy);
final Rect destinationRect = destinationPosition & destinationSize;
final bool needSave = repeat != ImageRepeat.noRepeat || flipHorizontally;
......
......@@ -72,7 +72,7 @@ class RenderAnimatedSize extends RenderAligningShiftedBox {
@required TickerProvider vsync,
@required Duration duration,
Curve curve: Curves.linear,
FractionalOffsetGeometry alignment: FractionalOffset.center,
AlignmentGeometry alignment: Alignment.center,
TextDirection textDirection,
RenderBox child,
}) : assert(vsync != null),
......
......@@ -32,7 +32,7 @@ class RenderImage extends RenderBox {
Color color,
BlendMode colorBlendMode,
BoxFit fit,
FractionalOffsetGeometry alignment: FractionalOffset.center,
AlignmentGeometry alignment: Alignment.center,
ImageRepeat repeat: ImageRepeat.noRepeat,
Rect centerSlice,
bool matchTextDirection: false,
......@@ -56,7 +56,7 @@ class RenderImage extends RenderBox {
_updateColorFilter();
}
FractionalOffset _resolvedAlignment;
Alignment _resolvedAlignment;
bool _flipHorizontally;
void _resolve() {
......@@ -178,9 +178,9 @@ class RenderImage extends RenderBox {
///
/// If this is set to a text-direction-dependent value, [textDirection] must
/// not be null.
FractionalOffsetGeometry get alignment => _alignment;
FractionalOffsetGeometry _alignment;
set alignment(FractionalOffsetGeometry value) {
AlignmentGeometry get alignment => _alignment;
AlignmentGeometry _alignment;
set alignment(AlignmentGeometry value) {
assert(value != null);
if (value == _alignment)
return;
......@@ -343,7 +343,7 @@ class RenderImage extends RenderBox {
description.add(new DiagnosticsProperty<Color>('color', color, defaultValue: null));
description.add(new EnumProperty<BlendMode>('colorBlendMode', colorBlendMode, defaultValue: null));
description.add(new EnumProperty<BoxFit>('fit', fit, defaultValue: null));
description.add(new DiagnosticsProperty<FractionalOffset>('alignment', alignment, defaultValue: null));
description.add(new DiagnosticsProperty<AlignmentGeometry>('alignment', alignment, defaultValue: null));
description.add(new EnumProperty<ImageRepeat>('repeat', repeat, defaultValue: ImageRepeat.noRepeat));
description.add(new DiagnosticsProperty<Rect>('centerSlice', centerSlice, defaultValue: null));
description.add(new FlagProperty('matchTextDirection', value: matchTextDirection, ifTrue: 'match text direction'));
......
......@@ -1599,11 +1599,10 @@ class RenderTransform extends RenderProxyBox {
RenderTransform({
@required Matrix4 transform,
Offset origin,
FractionalOffset alignment,
Alignment alignment,
this.transformHitTests: true,
RenderBox child
}) : assert(transform != null),
assert(alignment == null || (alignment.dx != null && alignment.dy != null)),
super(child) {
this.transform = transform;
this.alignment = alignment;
......@@ -1628,10 +1627,10 @@ class RenderTransform extends RenderProxyBox {
///
/// This is equivalent to setting an origin based on the size of the box.
/// If it is specified at the same time as an offset, both are applied.
FractionalOffset get alignment => _alignment;
FractionalOffset _alignment;
set alignment(FractionalOffset value) {
assert(value == null || (value.dx != null && value.dy != null));
Alignment get alignment => _alignment;
Alignment _alignment;
set alignment(Alignment value) {
assert(value == null || (value.x != null && value.y != null));
if (_alignment == value)
return;
_alignment = value;
......@@ -1751,7 +1750,7 @@ class RenderTransform extends RenderProxyBox {
super.debugFillProperties(description);
description.add(new TransformProperty('transform matrix', _transform));
description.add(new DiagnosticsProperty<Offset>('origin', origin));
description.add(new DiagnosticsProperty<FractionalOffset>('alignment', alignment));
description.add(new DiagnosticsProperty<Alignment>('alignment', alignment));
description.add(new DiagnosticsProperty<bool>('transformHitTests', transformHitTests));
}
}
......@@ -1764,9 +1763,9 @@ class RenderFittedBox extends RenderProxyBox {
RenderFittedBox({
RenderBox child,
BoxFit fit: BoxFit.contain,
FractionalOffset alignment: FractionalOffset.center
Alignment alignment: Alignment.center
}) : assert(fit != null),
assert(alignment != null && alignment.dx != null && alignment.dy != null),
assert(alignment != null),
_fit = fit,
_alignment = alignment,
super(child);
......@@ -1788,10 +1787,10 @@ class RenderFittedBox extends RenderProxyBox {
/// An alignment of (0.0, 0.0) aligns the child to the top-left corner of its
/// parent's bounds. An alignment of (1.0, 0.5) aligns the child to the middle
/// of the right edge of its parent's bounds.
FractionalOffset get alignment => _alignment;
FractionalOffset _alignment;
set alignment(FractionalOffset value) {
assert(value != null && value.dx != null && value.dy != null);
Alignment get alignment => _alignment;
Alignment _alignment;
set alignment(Alignment value) {
assert(value != null && value.x != null && value.y != null);
if (_alignment == value)
return;
_alignment = value;
......@@ -1891,13 +1890,13 @@ class RenderFittedBox extends RenderProxyBox {
void debugFillProperties(DiagnosticPropertiesBuilder description) {
super.debugFillProperties(description);
description.add(new EnumProperty<BoxFit>('fit', fit));
description.add(new DiagnosticsProperty<FractionalOffset>('alignment', alignment));
description.add(new DiagnosticsProperty<Alignment>('alignment', alignment));
}
}
/// Applies a translation transformation before painting its child.
///
/// The translation is expressed as a [FractionalOffset] relative to the
/// The translation is expressed as a [Alignment] relative to the
/// RenderFractionalTranslation box's size. Hit tests will only be detected
/// inside the bounds of the RenderFractionalTranslation, even if the contents
/// are offset such that they overflow.
......@@ -1906,18 +1905,18 @@ class RenderFractionalTranslation extends RenderProxyBox {
///
/// The [translation] argument must not be null.
RenderFractionalTranslation({
FractionalOffset translation,
Alignment translation,
this.transformHitTests: true,
RenderBox child
}) : assert(translation == null || (translation.dx != null && translation.dy != null)),
}) : assert(translation == null || (translation.x != null && translation.y != null)),
_translation = translation,
super(child);
/// The translation to apply to the child, as a multiple of the size.
FractionalOffset get translation => _translation;
FractionalOffset _translation;
set translation(FractionalOffset value) {
assert(value == null || (value.dx != null && value.dy != null));
/// The translation to apply to the child, relative to the child's center.
Alignment get translation => _translation;
Alignment _translation;
set translation(Alignment value) {
assert(value == null || (value.x != null && value.y != null));
if (_translation == value)
return;
_translation = value;
......@@ -1935,27 +1934,41 @@ class RenderFractionalTranslation extends RenderProxyBox {
@override
bool hitTest(HitTestResult result, { Offset position }) {
assert(!debugNeedsLayout);
if (transformHitTests)
position = new Offset(position.dx - translation.dx * size.width, position.dy - translation.dy * size.height);
if (transformHitTests) {
final double halfWidth = size.width / 2.0;
final double halfHeight = size.height / 2.0;
position = new Offset(
position.dx - translation.x * halfWidth,
position.dy - translation.y * halfHeight,
);
}
return super.hitTest(result, position: position);
}
@override
void paint(PaintingContext context, Offset offset) {
assert(!debugNeedsLayout);
if (child != null)
super.paint(context, offset + translation.alongSize(size));
if (child != null) {
final double halfWidth = size.width / 2.0;
final double halfHeight = size.height / 2.0;
super.paint(context, new Offset(
offset.dx + translation.x * halfWidth,
offset.dy + translation.y * halfHeight,
));
}
}
@override
void applyPaintTransform(RenderBox child, Matrix4 transform) {
transform.translate(translation.dx * size.width, translation.dy * size.height);
final double halfWidth = size.width / 2.0;
final double halfHeight = size.height / 2.0;
transform.translate(translation.x * halfWidth, translation.y * halfHeight);
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder description) {
super.debugFillProperties(description);
description.add(new DiagnosticsProperty<FractionalOffset>('translation', translation));
description.add(new DiagnosticsProperty<Alignment>('translation', translation));
description.add(new DiagnosticsProperty<bool>('transformHitTests', transformHitTests));
}
}
......@@ -1997,7 +2010,7 @@ class RenderFractionalTranslation extends RenderProxyBox {
/// void paint(Canvas canvas, Size size) {
/// var rect = Offset.zero & size;
/// var gradient = new RadialGradient(
/// center: const FractionalOffset(0.7, 0.2),
/// center: const Alignment(0.7, -0.6),
/// radius: 0.2,
/// colors: [const Color(0xFFFFFF00), const Color(0xFF0099FF)],
/// stops: [0.4, 1.0],
......
......@@ -222,13 +222,13 @@ class RenderPadding extends RenderShiftedBox {
}
/// Abstract class for one-child-layout render boxes that use a
/// [FractionalOffsetGeometry] to align their children.
/// [AlignmentGeometry] to align their children.
abstract class RenderAligningShiftedBox extends RenderShiftedBox {
/// Initializes member variables for subclasses.
///
/// The [alignment] argument must not be null.
RenderAligningShiftedBox({
FractionalOffsetGeometry alignment: FractionalOffset.center,
AlignmentGeometry alignment: Alignment.center,
TextDirection textDirection,
RenderBox child,
}) : assert(alignment != null),
......@@ -236,7 +236,7 @@ abstract class RenderAligningShiftedBox extends RenderShiftedBox {
_textDirection = textDirection,
super(child);
FractionalOffset _resolvedAlignment;
Alignment _resolvedAlignment;
void _resolve() {
if (_resolvedAlignment != null)
......@@ -252,21 +252,21 @@ abstract class RenderAligningShiftedBox extends RenderShiftedBox {
/// How to align the child.
///
/// The x and y values of the alignment control the horizontal and vertical
/// alignment, respectively. An x value of 0.0 means that the left edge of
/// alignment, respectively. An x value of -1.0 means that the left edge of
/// the child is aligned with the left edge of the parent whereas an x value
/// of 1.0 means that the right edge of the child is aligned with the right
/// edge of the parent. Other values interpolate (and extrapolate) linearly.
/// For example, a value of 0.5 means that the center of the child is aligned
/// For example, a value of 0.0 means that the center of the child is aligned
/// with the center of the parent.
///
/// If this is set to a [FractionalOffsetDirectional] object, then
/// If this is set to a [AlignmentDirectional] object, then
/// [textDirection] must not be null.
FractionalOffsetGeometry get alignment => _alignment;
FractionalOffsetGeometry _alignment;
AlignmentGeometry get alignment => _alignment;
AlignmentGeometry _alignment;
/// Sets the alignment to a new value, and triggers a layout update.
///
/// The new alignment must not be null or have any null properties.
set alignment(FractionalOffsetGeometry value) {
set alignment(AlignmentGeometry value) {
assert(value != null);
if (_alignment == value)
return;
......@@ -309,16 +309,16 @@ abstract class RenderAligningShiftedBox extends RenderShiftedBox {
@override
void debugFillProperties(DiagnosticPropertiesBuilder description) {
super.debugFillProperties(description);
description.add(new DiagnosticsProperty<FractionalOffsetGeometry>('alignment', alignment));
description.add(new DiagnosticsProperty<AlignmentGeometry>('alignment', alignment));
description.add(new EnumProperty<TextDirection>('textDirection', textDirection, defaultValue: null));
}
}
/// Positions its child using a [FractionalOffset].
/// Positions its child using a [AlignmentGeometry].
///
/// For example, to align a box at the bottom right, you would pass this box a
/// tight constraint that is bigger than the child's natural size,
/// with an alignment of [FractionalOffset.bottomRight].
/// with an alignment of [Alignment.bottomRight].
///
/// By default, sizes to be as big as possible in both axes. If either axis is
/// unconstrained, then in that direction it will be sized to fit the child's
......@@ -330,7 +330,7 @@ class RenderPositionedBox extends RenderAligningShiftedBox {
RenderBox child,
double widthFactor,
double heightFactor,
FractionalOffsetGeometry alignment: FractionalOffset.center,
AlignmentGeometry alignment: Alignment.center,
TextDirection textDirection,
}) : assert(widthFactor == null || widthFactor >= 0.0),
assert(heightFactor == null || heightFactor >= 0.0),
......@@ -475,7 +475,7 @@ class RenderConstrainedOverflowBox extends RenderAligningShiftedBox {
double maxWidth,
double minHeight,
double maxHeight,
FractionalOffsetGeometry alignment: FractionalOffset.center,
AlignmentGeometry alignment: Alignment.center,
TextDirection textDirection,
}) : _minWidth = minWidth,
_maxWidth = maxWidth,
......@@ -571,7 +571,7 @@ class RenderSizedOverflowBox extends RenderAligningShiftedBox {
RenderSizedOverflowBox({
RenderBox child,
@required Size requestedSize,
FractionalOffset alignment: FractionalOffset.center,
Alignment alignment: Alignment.center,
TextDirection textDirection,
}) : assert(requestedSize != null),
_requestedSize = requestedSize,
......@@ -643,7 +643,7 @@ class RenderFractionallySizedOverflowBox extends RenderAligningShiftedBox {
RenderBox child,
double widthFactor,
double heightFactor,
FractionalOffset alignment: FractionalOffset.center,
Alignment alignment: Alignment.center,
TextDirection textDirection,
}) : _widthFactor = widthFactor,
_heightFactor = heightFactor,
......
......@@ -297,7 +297,7 @@ class RenderStack extends RenderBox
/// top left corners.
RenderStack({
List<RenderBox> children,
FractionalOffsetGeometry alignment: FractionalOffsetDirectional.topStart,
AlignmentGeometry alignment: AlignmentDirectional.topStart,
TextDirection textDirection,
StackFit fit: StackFit.loose,
Overflow overflow: Overflow.clip,
......@@ -319,7 +319,7 @@ class RenderStack extends RenderBox
child.parentData = new StackParentData();
}
FractionalOffset _resolvedAlignment;
Alignment _resolvedAlignment;
void _resolve() {
if (_resolvedAlignment != null)
......@@ -336,14 +336,14 @@ class RenderStack extends RenderBox
///
/// The non-positioned children are placed relative to each other such that
/// the points determined by [alignment] are co-located. For example, if the
/// [alignment] is [FractionalOffset.topLeft], then the top left corner of
/// [alignment] is [Alignment.topLeft], then the top left corner of
/// each non-positioned child will be located at the same global coordinate.
///
/// If this is set to a [FractionalOffsetDirectional] object, then
/// [textDirection] must not be null.
FractionalOffsetGeometry get alignment => _alignment;
FractionalOffsetGeometry _alignment;
set alignment(FractionalOffsetGeometry value) {
/// If this is set to a [AlignmentDirectional] object, then [textDirection]
/// must not be null.
AlignmentGeometry get alignment => _alignment;
AlignmentGeometry _alignment;
set alignment(AlignmentGeometry value) {
assert(value != null);
if (_alignment == value)
return;
......@@ -559,7 +559,7 @@ class RenderStack extends RenderBox
@override
void debugFillProperties(DiagnosticPropertiesBuilder description) {
super.debugFillProperties(description);
description.add(new DiagnosticsProperty<FractionalOffsetGeometry>('alignment', alignment));
description.add(new DiagnosticsProperty<AlignmentGeometry>('alignment', alignment));
description.add(new EnumProperty<TextDirection>('textDirection', textDirection));
description.add(new EnumProperty<StackFit>('fit', fit));
description.add(new EnumProperty<Overflow>('overflow', overflow));
......@@ -577,7 +577,7 @@ class RenderIndexedStack extends RenderStack {
/// If the [index] parameter is null, nothing is displayed.
RenderIndexedStack({
List<RenderBox> children,
FractionalOffsetGeometry alignment: FractionalOffsetDirectional.topStart,
AlignmentGeometry alignment: AlignmentDirectional.topStart,
TextDirection textDirection,
int index: 0,
}) : _index = index, super(
......
......@@ -7,15 +7,14 @@ import 'package:flutter/painting.dart';
/// An interpolation between two fractional offsets.
///
/// This class specializes the interpolation of Tween<FractionalOffset> to be
/// appropriate for rectangles.
/// This class specializes the interpolation of [Tween<FractionalOffset>] to be
/// appropriate for fractional offsets.
///
/// See [Tween] for a discussion on how to use interpolation objects.
///
/// See also:
///
/// * [FractionalOffsetGeometryTween], which interpolates between two
/// [FractionalOffsetGeometry] objects.
/// * [AlignmentTween], which interpolates between to [Alignment] objects.
class FractionalOffsetTween extends Tween<FractionalOffset> {
/// Creates a fractional offset tween.
///
......@@ -29,28 +28,51 @@ class FractionalOffsetTween extends Tween<FractionalOffset> {
FractionalOffset lerp(double t) => FractionalOffset.lerp(begin, end, t);
}
/// An interpolation between two [FractionalOffsetGeometry].
/// An interpolation between two alignments.
///
/// This class specializes the interpolation of [Tween<FractionalOffsetGeometry>]
/// to be appropriate for rectangles.
/// This class specializes the interpolation of [Tween<Alignment>] to be
/// appropriate for alignments.
///
/// See [Tween] for a discussion on how to use interpolation objects.
///
/// See also:
///
/// * [FractionalOffsetTween], which interpolates between two
/// [FractionalOffset] objects.
class FractionalOffsetGeometryTween extends Tween<FractionalOffsetGeometry> {
/// * [AlignmentGeometryTween], which interpolates between two
/// [AlignmentGeometry] objects.
class AlignmentTween extends Tween<Alignment> {
/// Creates a fractional offset tween.
///
/// The [begin] and [end] properties may be null; the null value
/// is treated as meaning the center.
AlignmentTween({ Alignment begin, Alignment end })
: super(begin: begin, end: end);
/// Returns the value this variable has at the given animation clock value.
@override
Alignment lerp(double t) => Alignment.lerp(begin, end, t);
}
/// An interpolation between two [AlignmentGeometry].
///
/// This class specializes the interpolation of [Tween<AlignmentGeometry>]
/// to be appropriate for alignments.
///
/// See [Tween] for a discussion on how to use interpolation objects.
///
/// See also:
///
/// * [AlignmentTween], which interpolates between two [Alignment] objects.
class AlignmentGeometryTween extends Tween<AlignmentGeometry> {
/// Creates a fractional offset geometry tween.
///
/// The [begin] and [end] properties may be null; the null value
/// is treated as meaning the center.
FractionalOffsetGeometryTween({
FractionalOffsetGeometry begin,
FractionalOffsetGeometry end,
AlignmentGeometryTween({
AlignmentGeometry begin,
AlignmentGeometry end,
}) : super(begin: begin, end: end);
/// Returns the value this variable has at the given animation clock value.
@override
FractionalOffsetGeometry lerp(double t) => FractionalOffsetGeometry.lerp(begin, end, t);
AlignmentGeometry lerp(double t) => AlignmentGeometry.lerp(begin, end, t);
}
......@@ -115,7 +115,7 @@ class AnimatedCrossFade extends StatefulWidget {
this.firstCurve: Curves.linear,
this.secondCurve: Curves.linear,
this.sizeCurve: Curves.linear,
this.alignment: FractionalOffset.topCenter,
this.alignment: Alignment.topCenter,
@required this.crossFadeState,
@required this.duration,
this.layoutBuilder: defaultLayoutBuilder,
......@@ -165,8 +165,8 @@ class AnimatedCrossFade extends StatefulWidget {
/// How the children should be aligned while the size is animating.
///
/// Defaults to [FractionalOffset.topCenter].
final FractionalOffsetGeometry alignment;
/// Defaults to [Alignment.topCenter].
final AlignmentGeometry alignment;
/// A builder that positions the [firstChild] and [secondChild] widgets.
///
......@@ -218,7 +218,7 @@ class AnimatedCrossFade extends StatefulWidget {
void debugFillProperties(DiagnosticPropertiesBuilder description) {
super.debugFillProperties(description);
description.add(new EnumProperty<CrossFadeState>('crossFadeState', crossFadeState));
description.add(new DiagnosticsProperty<FractionalOffsetGeometry>('alignment', alignment, defaultValue: FractionalOffset.topCenter));
description.add(new DiagnosticsProperty<AlignmentGeometry>('alignment', alignment, defaultValue: Alignment.topCenter));
}
}
......@@ -356,6 +356,6 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> with TickerProvid
super.debugFillProperties(description);
description.add(new EnumProperty<CrossFadeState>('crossFadeState', widget.crossFadeState));
description.add(new DiagnosticsProperty<AnimationController>('controller', _controller, showName: false));
description.add(new DiagnosticsProperty<FractionalOffsetGeometry>('alignment', widget.alignment, defaultValue: FractionalOffset.topCenter));
description.add(new DiagnosticsProperty<AlignmentGeometry>('alignment', widget.alignment, defaultValue: Alignment.topCenter));
}
}
......@@ -18,7 +18,7 @@ class AnimatedSize extends SingleChildRenderObjectWidget {
const AnimatedSize({
Key key,
Widget child,
this.alignment: FractionalOffset.center,
this.alignment: Alignment.center,
this.curve: Curves.linear,
@required this.duration,
@required this.vsync,
......@@ -28,13 +28,13 @@ class AnimatedSize extends SingleChildRenderObjectWidget {
/// the same size as the child.
///
/// The x and y values of the alignment control the horizontal and vertical
/// alignment, respectively. An x value of 0.0 means that the left edge of
/// alignment, respectively. An x value of -1.0 means that the left edge of
/// the child is aligned with the left edge of the parent whereas an x value
/// of 1.0 means that the right edge of the child is aligned with the right
/// edge of the parent. Other values interpolate (and extrapolate) linearly.
/// For example, a value of 0.5 means that the center of the child is aligned
/// For example, a value of 0.0 means that the center of the child is aligned
/// with the center of the parent.
final FractionalOffsetGeometry alignment;
final AlignmentGeometry alignment;
/// The animation curve when transitioning this widget's size to match the
/// child's size.
......
This diff is collapsed.
......@@ -25,7 +25,7 @@ import 'image.dart';
/// new DecoratedBox(
/// decoration: new BoxDecoration(
/// gradient: new RadialGradient(
/// center: const FractionalOffset(0.25, 0.3),
/// center: const Alignment(-0.5, -0.6),
/// radius: 0.15,
/// colors: <Color>[
/// const Color(0xFFEEEEEE),
......@@ -207,7 +207,7 @@ class DecoratedBox extends SingleChildRenderObjectWidget {
/// ),
/// padding: const EdgeInsets.all(8.0),
/// color: Colors.teal.shade700,
/// alignment: FractionalOffset.center,
/// alignment: Alignment.center,
/// child: new Text('Hello World', style: Theme.of(context).textTheme.display1.copyWith(color: Colors.white)),
/// foregroundDecoration: new BoxDecoration(
/// image: new DecorationImage(
......@@ -278,7 +278,7 @@ class Container extends StatelessWidget {
/// constraints are unbounded, then the child will be shrink-wrapped instead.
///
/// Ignored if [child] is null.
final FractionalOffsetGeometry alignment;
final AlignmentGeometry alignment;
/// Empty space to inscribe inside the [decoration]. The [child], if any, is
/// placed inside this padding.
......@@ -362,7 +362,7 @@ class Container extends StatelessWidget {
@override
void debugFillProperties(DiagnosticPropertiesBuilder description) {
super.debugFillProperties(description);
description.add(new DiagnosticsProperty<FractionalOffsetGeometry>('alignment', alignment, showName: false, defaultValue: null));
description.add(new DiagnosticsProperty<AlignmentGeometry>('alignment', alignment, showName: false, defaultValue: null));
description.add(new DiagnosticsProperty<EdgeInsetsGeometry>('padding', padding, defaultValue: null));
description.add(new DiagnosticsProperty<Decoration>('bg', decoration, defaultValue: null));
description.add(new DiagnosticsProperty<Decoration>('fg', foregroundDecoration, defaultValue: null));
......
......@@ -232,7 +232,7 @@ bool debugCheckHasDirectionality(BuildContext context) {
'determines the ambient reading direction and is used, for example, to '
'determine how to lay out text, how to interpret "start" and "end" '
'values, and to resolve EdgeInsetsDirectional, '
'FractionalOffsetDirectional, and other *Directional objects.'
'AlignmentDirectional, and other *Directional objects.'
);
}
return true;
......
......@@ -135,19 +135,21 @@ class _DismissibleClipper extends CustomClipper<Rect> {
super(reclip: moveAnimation);
final Axis axis;
final Animation<FractionalOffset> moveAnimation;
final Animation<Alignment> moveAnimation;
@override
Rect getClip(Size size) {
assert(axis != null);
switch (axis) {
case Axis.horizontal:
final double offset = moveAnimation.value.dx * size.width;
final double halfWidth = size.width / 2.0;
final double offset = halfWidth + moveAnimation.value.x * halfWidth;
if (offset < 0)
return new Rect.fromLTRB(size.width + offset, 0.0, size.width, size.height);
return new Rect.fromLTRB(0.0, 0.0, offset, size.height);
case Axis.vertical:
final double offset = moveAnimation.value.dy * size.height;
final double halfHeight = size.height / 2.0;
final double offset = halfHeight + moveAnimation.value.y * halfHeight;
if (offset < 0)
return new Rect.fromLTRB(0.0, size.height + offset, size.width, size.height);
return new Rect.fromLTRB(0.0, 0.0, size.width, offset);
......@@ -175,7 +177,7 @@ class _DismissibleState extends State<Dismissible> with TickerProviderStateMixin
}
AnimationController _moveController;
Animation<FractionalOffset> _moveAnimation;
Animation<Alignment> _moveAnimation;
AnimationController _resizeController;
Animation<double> _resizeAnimation;
......@@ -268,11 +270,10 @@ class _DismissibleState extends State<Dismissible> with TickerProviderStateMixin
}
void _updateMoveAnimation() {
_moveAnimation = new FractionalOffsetTween(
begin: FractionalOffset.topLeft,
end: _directionIsXAxis ?
new FractionalOffset(_dragExtent.sign, 0.0) :
new FractionalOffset(0.0, _dragExtent.sign)
final double end = _dragExtent.sign * 2.0;
_moveAnimation = new AlignmentTween(
begin: Alignment.center,
end: _directionIsXAxis ? new Alignment(end, 0.0) : new Alignment(0.0, end),
).animate(_moveController);
}
......
......@@ -73,7 +73,7 @@ class FadeInImage extends StatefulWidget {
this.width,
this.height,
this.fit,
this.alignment: FractionalOffset.center,
this.alignment: Alignment.center,
this.repeat: ImageRepeat.noRepeat,
this.matchTextDirection: false,
}) : assert(placeholder != null),
......@@ -121,7 +121,7 @@ class FadeInImage extends StatefulWidget {
this.width,
this.height,
this.fit,
this.alignment: FractionalOffset.center,
this.alignment: Alignment.center,
this.repeat: ImageRepeat.noRepeat,
this.matchTextDirection: false,
}) : assert(placeholder != null),
......@@ -177,7 +177,7 @@ class FadeInImage extends StatefulWidget {
this.width,
this.height,
this.fit,
this.alignment: FractionalOffset.center,
this.alignment: Alignment.center,
this.repeat: ImageRepeat.noRepeat,
this.matchTextDirection: false,
}) : assert(placeholder != null),
......@@ -239,19 +239,19 @@ class FadeInImage extends StatefulWidget {
/// How to align the image within its bounds.
///
/// The alignment aligns the given position in the image to the given position
/// in the layout bounds. For example, a [FractionalOffset] alignment of (0.0,
/// 0.0) aligns the image to the top-left corner of its layout bounds, while a
/// [FractionalOffset] alignment of (1.0, 1.0) aligns the bottom right of the
/// in the layout bounds. For example, a [Alignment] alignment of (-1.0,
/// -1.0) aligns the image to the top-left corner of its layout bounds, while a
/// [Alignment] alignment of (1.0, 1.0) aligns the bottom right of the
/// image with the bottom right corner of its layout bounds. Similarly, an
/// alignment of (0.5, 1.0) aligns the bottom middle of the image with the
/// alignment of (0.0, 1.0) aligns the bottom middle of the image with the
/// middle of the bottom edge of its layout bounds.
///
/// If the [alignment] is [TextDirection]-dependent (i.e. if it is a
/// [FractionalOffsetDirectional]), then an ambient [Directionality] widget
/// [AlignmentDirectional]), then an ambient [Directionality] widget
/// must be in scope.
///
/// Defaults to [FractionalOffset.center].
final FractionalOffsetGeometry alignment;
/// Defaults to [Alignment.center].
final AlignmentGeometry alignment;
/// How to paint any portions of the layout bounds not covered by the image.
final ImageRepeat repeat;
......
......@@ -113,7 +113,7 @@ class Image extends StatefulWidget {
this.color,
this.colorBlendMode,
this.fit,
this.alignment: FractionalOffset.center,
this.alignment: Alignment.center,
this.repeat: ImageRepeat.noRepeat,
this.centerSlice,
this.matchTextDirection: false,
......@@ -136,7 +136,7 @@ class Image extends StatefulWidget {
this.color,
this.colorBlendMode,
this.fit,
this.alignment: FractionalOffset.center,
this.alignment: Alignment.center,
this.repeat: ImageRepeat.noRepeat,
this.centerSlice,
this.matchTextDirection: false,
......@@ -162,7 +162,7 @@ class Image extends StatefulWidget {
this.color,
this.colorBlendMode,
this.fit,
this.alignment: FractionalOffset.center,
this.alignment: Alignment.center,
this.repeat: ImageRepeat.noRepeat,
this.centerSlice,
this.matchTextDirection: false,
......@@ -293,7 +293,7 @@ class Image extends StatefulWidget {
this.color,
this.colorBlendMode,
this.fit,
this.alignment: FractionalOffset.center,
this.alignment: Alignment.center,
this.repeat: ImageRepeat.noRepeat,
this.centerSlice,
this.matchTextDirection: false,
......@@ -318,7 +318,7 @@ class Image extends StatefulWidget {
this.color,
this.colorBlendMode,
this.fit,
this.alignment: FractionalOffset.center,
this.alignment: Alignment.center,
this.repeat: ImageRepeat.noRepeat,
this.centerSlice,
this.matchTextDirection: false,
......@@ -367,22 +367,22 @@ class Image extends StatefulWidget {
/// How to align the image within its bounds.
///
/// The alignment aligns the given position in the image to the given position
/// in the layout bounds. For example, a [FractionalOffset] alignment of (0.0,
/// 0.0) aligns the image to the top-left corner of its layout bounds, while a
/// [FractionalOffset] alignment of (1.0, 1.0) aligns the bottom right of the
/// in the layout bounds. For example, a [Alignment] alignment of (-1.0,
/// -1.0) aligns the image to the top-left corner of its layout bounds, while a
/// [Alignment] alignment of (1.0, 1.0) aligns the bottom right of the
/// image with the bottom right corner of its layout bounds. Similarly, an
/// alignment of (0.5, 1.0) aligns the bottom middle of the image with the
/// alignment of (0.0, 1.0) aligns the bottom middle of the image with the
/// middle of the bottom edge of its layout bounds.
///
/// To display a subpart of an image, consider using a [CustomPainter] and
/// [Canvas.drawImageRect].
///
/// If the [alignment] is [TextDirection]-dependent (i.e. if it is a
/// [FractionalOffsetDirectional]), then an ambient [Directionality] widget
/// [AlignmentDirectional]), then an ambient [Directionality] widget
/// must be in scope.
///
/// Defaults to [FractionalOffset.center].
final FractionalOffsetGeometry alignment;
/// Defaults to [Alignment.center].
final AlignmentGeometry alignment;
/// How to paint any portions of the layout bounds not covered by the image.
final ImageRepeat repeat;
......@@ -433,7 +433,7 @@ class Image extends StatefulWidget {
description.add(new DiagnosticsProperty<Color>('color', color, defaultValue: null));
description.add(new EnumProperty<BlendMode>('colorBlendMode', colorBlendMode, defaultValue: null));
description.add(new EnumProperty<BoxFit>('fit', fit, defaultValue: null));
description.add(new DiagnosticsProperty<FractionalOffsetGeometry>('alignment', alignment, defaultValue: null));
description.add(new DiagnosticsProperty<AlignmentGeometry>('alignment', alignment, defaultValue: null));
description.add(new EnumProperty<ImageRepeat>('repeat', repeat, defaultValue: ImageRepeat.noRepeat));
description.add(new DiagnosticsProperty<Rect>('centerSlice', centerSlice, defaultValue: null));
description.add(new FlagProperty('matchTextDirection', value: matchTextDirection, ifTrue: 'match text direction'));
......
......@@ -75,7 +75,7 @@ class ImageIcon extends StatelessWidget {
height: iconSize,
color: iconColor,
fit: BoxFit.scaleDown,
alignment: FractionalOffset.center
alignment: Alignment.center,
);
}
......
......@@ -391,7 +391,7 @@ class AnimatedContainer extends ImplicitlyAnimatedWidget {
/// constraints are unbounded, then the child will be shrink-wrapped instead.
///
/// Ignored if [child] is null.
final FractionalOffsetGeometry alignment;
final AlignmentGeometry alignment;
/// Empty space to inscribe inside the [decoration]. The [child], if any, is
/// placed inside this padding.
......@@ -427,7 +427,7 @@ class AnimatedContainer extends ImplicitlyAnimatedWidget {
@override
void debugFillProperties(DiagnosticPropertiesBuilder description) {
super.debugFillProperties(description);
description.add(new DiagnosticsProperty<FractionalOffsetGeometry>('alignment', alignment, showName: false, defaultValue: null));
description.add(new DiagnosticsProperty<AlignmentGeometry>('alignment', alignment, showName: false, defaultValue: null));
description.add(new DiagnosticsProperty<EdgeInsetsGeometry>('padding', padding, defaultValue: null));
description.add(new DiagnosticsProperty<Decoration>('bg', decoration, defaultValue: null));
description.add(new DiagnosticsProperty<Decoration>('fg', foregroundDecoration, defaultValue: null));
......@@ -438,7 +438,7 @@ class AnimatedContainer extends ImplicitlyAnimatedWidget {
}
class _AnimatedContainerState extends AnimatedWidgetBaseState<AnimatedContainer> {
FractionalOffsetGeometryTween _alignment;
AlignmentGeometryTween _alignment;
EdgeInsetsGeometryTween _padding;
DecorationTween _decoration;
DecorationTween _foregroundDecoration;
......@@ -448,7 +448,7 @@ class _AnimatedContainerState extends AnimatedWidgetBaseState<AnimatedContainer>
@override
void forEachTween(TweenVisitor<dynamic> visitor) {
_alignment = visitor(_alignment, widget.alignment, (dynamic value) => new FractionalOffsetGeometryTween(begin: value));
_alignment = visitor(_alignment, widget.alignment, (dynamic value) => new AlignmentGeometryTween(begin: value));
_padding = visitor(_padding, widget.padding, (dynamic value) => new EdgeInsetsGeometryTween(begin: value));
_decoration = visitor(_decoration, widget.decoration, (dynamic value) => new DecorationTween(begin: value));
_foregroundDecoration = visitor(_foregroundDecoration, widget.foregroundDecoration, (dynamic value) => new DecorationTween(begin: value));
......@@ -474,7 +474,7 @@ class _AnimatedContainerState extends AnimatedWidgetBaseState<AnimatedContainer>
@override
void debugFillProperties(DiagnosticPropertiesBuilder description) {
super.debugFillProperties(description);
description.add(new DiagnosticsProperty<FractionalOffsetGeometryTween>('alignment', _alignment, showName: false, defaultValue: null));
description.add(new DiagnosticsProperty<AlignmentGeometryTween>('alignment', _alignment, showName: false, defaultValue: null));
description.add(new DiagnosticsProperty<EdgeInsetsGeometryTween>('padding', _padding, defaultValue: null));
description.add(new DiagnosticsProperty<DecorationTween>('bg', _decoration, defaultValue: null));
description.add(new DiagnosticsProperty<DecorationTween>('fg', _foregroundDecoration, defaultValue: null));
......
......@@ -632,9 +632,9 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
/// Widget child,
/// ) {
/// return new SlideTransition(
/// position: new FractionalOffsetTween(
/// begin: FractionalOffset.bottomLeft,
/// end: FractionalOffset.topLeft
/// position: new AlignmentTween(
/// begin: Alignment.bottomCenter,
/// end: Alignment.topCenter,
/// ).animate(animation),
/// child: child, // child is the value returned by pageBuilder
/// );
......@@ -669,14 +669,14 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
/// Widget child,
/// ) {
/// return new SlideTransition(
/// position: new FractionalOffsetTween(
/// begin: FractionalOffset.bottomLeft,
/// end: FractionalOffset.topLeft,
/// position: new AlignmentTween(
/// begin: Alignment.bottomCenter,
/// end: Alignment.topCenter,
/// ).animate(animation),
/// child: new SlideTransition(
/// position: new FractionalOffsetTween(
/// begin: FractionalOffset.topLeft,
/// end: FractionalOffset.bottomLeft,
/// position: new AlignmentTween(
/// begin: Alignment.topCenter,
/// end: Alignment.bottomCenter,
/// ).animate(secondaryAnimation),
/// child: child,
/// ),
......
......@@ -279,7 +279,7 @@ abstract class ScrollView extends StatelessWidget {
/// delegate: new SliverChildBuilderDelegate(
/// (BuildContext context, int index) {
/// return new Container(
/// alignment: FractionalOffset.center,
/// alignment: Alignment.center,
/// color: Colors.teal[100 * (index % 9)],
/// child: new Text('grid item $index'),
/// );
......@@ -292,7 +292,7 @@ abstract class ScrollView extends StatelessWidget {
/// delegate: new SliverChildBuilderDelegate(
/// (BuildContext context, int index) {
/// return new Container(
/// alignment: FractionalOffset.center,
/// alignment: Alignment.center,
/// color: Colors.lightBlue[100 * (index % 9)],
/// child: new Text('list item $index'),
/// );
......
......@@ -279,7 +279,7 @@ void _paintMessage(Canvas canvas, SemanticsNode node) {
..textAlign = TextAlign.center
..layout(maxWidth: rect.width);
textPainter.paint(canvas, FractionalOffset.center.inscribe(textPainter.size, rect).topLeft);
textPainter.paint(canvas, Alignment.center.inscribe(textPainter.size, rect).topLeft);
canvas.restore();
}
......
......@@ -422,7 +422,7 @@ class SliverList extends SliverMultiBoxAdaptorWidget {
/// delegate: new SliverChildBuilderDelegate(
/// (BuildContext context, int index) {
/// return new Container(
/// alignment: FractionalOffset.center,
/// alignment: Alignment.center,
/// color: Colors.lightBlue[100 * (index % 9)],
/// child: new Text('list item $index'),
/// );
......@@ -489,7 +489,7 @@ class SliverFixedExtentList extends SliverMultiBoxAdaptorWidget {
/// delegate: new SliverChildBuilderDelegate(
/// (BuildContext context, int index) {
/// return new Container(
/// alignment: FractionalOffset.center,
/// alignment: Alignment.center,
/// color: Colors.teal[100 * (index % 9)],
/// child: new Text('grid item $index'),
/// );
......
......@@ -103,7 +103,7 @@ class SlideTransition extends AnimatedWidget {
/// The [position] argument must not be null.
const SlideTransition({
Key key,
@required Animation<FractionalOffsetGeometry> position,
@required Animation<Alignment> position,
this.transformHitTests: true,
this.child,
}) : super(key: key, listenable: position);
......@@ -112,7 +112,7 @@ class SlideTransition extends AnimatedWidget {
///
/// If the current value of the position animation is (dx, dy), the child will
/// be translated horizontally by width * dx and vertically by height * dy.
Animation<FractionalOffsetGeometry> get position => listenable;
Animation<Alignment> get position => listenable;
/// Whether hit testing should be affected by the slide animation.
///
......@@ -140,11 +140,11 @@ class ScaleTransition extends AnimatedWidget {
/// Creates a scale transition.
///
/// The [scale] argument must not be null. The [alignment] argument defaults
/// to [FractionalOffset.center].
/// to [Alignment.center].
const ScaleTransition({
Key key,
@required Animation<double> scale,
this.alignment: FractionalOffset.center,
this.alignment: Alignment.center,
this.child,
}) : super(key: key, listenable: scale);
......@@ -158,8 +158,8 @@ class ScaleTransition extends AnimatedWidget {
/// takes place, relative to the size of the box.
///
/// For example, to set the origin of the scale to bottom middle, you can use
/// an alignment of (0.5, 1.0).
final FractionalOffset alignment;
/// an alignment of (0.0, 1.0).
final Alignment alignment;
/// The widget below this widget in the tree.
final Widget child;
......@@ -203,7 +203,7 @@ class RotationTransition extends AnimatedWidget {
final Matrix4 transform = new Matrix4.rotationZ(turnsValue * math.PI * 2.0);
return new Transform(
transform: transform,
alignment: FractionalOffset.center,
alignment: Alignment.center,
child: child,
);
}
......@@ -217,13 +217,13 @@ class SizeTransition extends AnimatedWidget {
/// Creates a size transition.
///
/// The [sizeFactor] argument must not be null. The [axis] argument defaults
/// to [Axis.vertical]. The [axisAlignment] defaults to 0.5, which centers the
/// to [Axis.vertical]. The [axisAlignment] defaults to 0.0, which centers the
/// child along the main axis during the transition.
const SizeTransition({
Key key,
this.axis: Axis.vertical,
@required Animation<double> sizeFactor,
this.axisAlignment: 0.5,
this.axisAlignment: 0.0,
this.child,
}) : assert(axis != null),
super(key: key, listenable: sizeFactor);
......@@ -244,11 +244,11 @@ class SizeTransition extends AnimatedWidget {
@override
Widget build(BuildContext context) {
FractionalOffsetDirectional alignment;
AlignmentDirectional alignment;
if (axis == Axis.vertical)
alignment = new FractionalOffsetDirectional(0.0, axisAlignment);
alignment = new AlignmentDirectional(-1.0, axisAlignment);
else
alignment = new FractionalOffsetDirectional(axisAlignment, 0.0);
alignment = new AlignmentDirectional(axisAlignment, -1.0);
return new ClipRect(
child: new Align(
alignment: alignment,
......
......@@ -33,13 +33,13 @@ void main() {
Offset widget2TopLeft = tester.getTopLeft(find.text('Page 2'));
// Page 1 is moving to the left.
expect(widget1TransientTopLeft.dx < widget1InitialTopLeft.dx, true);
expect(widget1TransientTopLeft.dx, lessThan(widget1InitialTopLeft.dx));
// Page 1 isn't moving vertically.
expect(widget1TransientTopLeft.dy == widget1InitialTopLeft.dy, true);
expect(widget1TransientTopLeft.dy, equals(widget1InitialTopLeft.dy));
// iOS transition is horizontal only.
expect(widget1InitialTopLeft.dy == widget2TopLeft.dy, true);
expect(widget1InitialTopLeft.dy, equals(widget2TopLeft.dy));
// Page 2 is coming in from the right.
expect(widget2TopLeft.dx > widget1InitialTopLeft.dx, true);
expect(widget2TopLeft.dx, greaterThan(widget1InitialTopLeft.dx));
await tester.pumpAndSettle();
......@@ -55,13 +55,13 @@ void main() {
widget2TopLeft = tester.getTopLeft(find.text('Page 2'));
// Page 1 is coming back from the left.
expect(widget1TransientTopLeft.dx < widget1InitialTopLeft.dx, true);
expect(widget1TransientTopLeft.dx, lessThan(widget1InitialTopLeft.dx));
// Page 1 isn't moving vertically.
expect(widget1TransientTopLeft.dy == widget1InitialTopLeft.dy, true);
expect(widget1TransientTopLeft.dy, equals(widget1InitialTopLeft.dy));
// iOS transition is horizontal only.
expect(widget1InitialTopLeft.dy == widget2TopLeft.dy, true);
expect(widget1InitialTopLeft.dy, equals(widget2TopLeft.dy));
// Page 2 is leaving towards the right.
expect(widget2TopLeft.dx > widget1InitialTopLeft.dx, true);
expect(widget2TopLeft.dx, greaterThan(widget1InitialTopLeft.dx));
await tester.pumpAndSettle();
......@@ -71,7 +71,7 @@ void main() {
widget1TransientTopLeft = tester.getTopLeft(find.text('Page 1'));
// Page 1 is back where it started.
expect(widget1InitialTopLeft == widget1TransientTopLeft, true);
expect(widget1InitialTopLeft, equals(widget1TransientTopLeft));
});
testWidgets('test iOS fullscreen dialog transition', (WidgetTester tester) async {
......@@ -105,11 +105,11 @@ void main() {
Offset widget2TopLeft = tester.getTopLeft(find.text('Page 2'));
// Page 1 doesn't move.
expect(widget1TransientTopLeft == widget1InitialTopLeft, true);
expect(widget1TransientTopLeft, equals(widget1InitialTopLeft));
// Fullscreen dialogs transitions vertically only.
expect(widget1InitialTopLeft.dx == widget2TopLeft.dx, true);
expect(widget1InitialTopLeft.dx, equals(widget2TopLeft.dx));
// Page 2 is coming in from the bottom.
expect(widget2TopLeft.dy > widget1InitialTopLeft.dy, true);
expect(widget2TopLeft.dy, greaterThan(widget1InitialTopLeft.dy));
await tester.pumpAndSettle();
......@@ -125,11 +125,11 @@ void main() {
widget2TopLeft = tester.getTopLeft(find.text('Page 2'));
// Page 1 doesn't move.
expect(widget1TransientTopLeft == widget1InitialTopLeft, true);
expect(widget1TransientTopLeft, equals(widget1InitialTopLeft));
// Fullscreen dialogs transitions vertically only.
expect(widget1InitialTopLeft.dx == widget2TopLeft.dx, true);
expect(widget1InitialTopLeft.dx, equals(widget2TopLeft.dx));
// Page 2 is leaving towards the bottom.
expect(widget2TopLeft.dy > widget1InitialTopLeft.dy, true);
expect(widget2TopLeft.dy, greaterThan(widget1InitialTopLeft.dy));
await tester.pumpAndSettle();
......@@ -139,7 +139,7 @@ void main() {
widget1TransientTopLeft = tester.getTopLeft(find.text('Page 1'));
// Page 1 is back where it started.
expect(widget1InitialTopLeft == widget1TransientTopLeft, true);
expect(widget1InitialTopLeft, equals(widget1TransientTopLeft));
});
testWidgets('test only edge swipes work', (WidgetTester tester) async {
......
......@@ -999,8 +999,8 @@ void main() {
flexibleSpace: new DecoratedBox(
decoration: new BoxDecoration(
gradient: new LinearGradient(
begin: const FractionalOffset(0.50, 0.0),
end: const FractionalOffset(0.48, 1.0),
begin: const Alignment(0.0, -1.0),
end: const Alignment(-0.04, 1.0),
colors: <Color>[Colors.blue.shade500, Colors.blue.shade800],
),
),
......@@ -1029,8 +1029,8 @@ void main() {
flexibleSpace: new DecoratedBox(
decoration: new BoxDecoration(
gradient: new LinearGradient(
begin: const FractionalOffset(0.50, 0.0),
end: const FractionalOffset(0.48, 1.0),
begin: const Alignment(0.0, -1.0),
end: const Alignment(-0.04, 1.0),
colors: <Color>[Colors.blue.shade500, Colors.blue.shade800],
),
),
......
......@@ -160,7 +160,7 @@ void main() {
child: new Container(
width: 100.0,
height: 100.0,
alignment: FractionalOffset.center,
alignment: Alignment.center,
child: const Text('Dialog1'),
),
);
......@@ -180,7 +180,7 @@ void main() {
child: new Container(
width: 100.0,
height: 100.0,
alignment: FractionalOffset.center,
alignment: Alignment.center,
child: const Text('Dialog2'),
),
);
......
......@@ -24,7 +24,7 @@ Widget buildFrame({
bool isDense: false,
Widget hint,
List<String> items: menuItems,
FractionalOffset alignment: FractionalOffset.center,
Alignment alignment: Alignment.center,
}) {
return new MaterialApp(
home: new Material(
......@@ -219,7 +219,7 @@ void main() {
new MaterialApp(
home: new Material(
child: new Align(
alignment: FractionalOffset.topCenter,
alignment: Alignment.topCenter,
child: button,
),
),
......@@ -443,19 +443,19 @@ void main() {
// so that it fits within the frame.
await popUpAndDown(
buildFrame(alignment: FractionalOffset.topLeft, value: menuItems.last)
buildFrame(alignment: Alignment.topLeft, value: menuItems.last)
);
expect(menuRect.topLeft, Offset.zero);
expect(menuRect.topRight, new Offset(menuRect.width, 0.0));
await popUpAndDown(
buildFrame(alignment: FractionalOffset.topCenter, value: menuItems.last)
buildFrame(alignment: Alignment.topCenter, value: menuItems.last)
);
expect(menuRect.topLeft, new Offset(buttonRect.left, 0.0));
expect(menuRect.topRight, new Offset(buttonRect.right, 0.0));
await popUpAndDown(
buildFrame(alignment: FractionalOffset.topRight, value: menuItems.last)
buildFrame(alignment: Alignment.topRight, value: menuItems.last)
);
expect(menuRect.topLeft, new Offset(800.0 - menuRect.width, 0.0));
expect(menuRect.topRight, const Offset(800.0, 0.0));
......@@ -465,19 +465,19 @@ void main() {
// is selected) and shifted horizontally so that it fits within the frame.
await popUpAndDown(
buildFrame(alignment: FractionalOffset.centerLeft, value: menuItems.first)
buildFrame(alignment: Alignment.centerLeft, value: menuItems.first)
);
expect(menuRect.topLeft, new Offset(0.0, buttonRect.top));
expect(menuRect.topRight, new Offset(menuRect.width, buttonRect.top));
await popUpAndDown(
buildFrame(alignment: FractionalOffset.center, value: menuItems.first)
buildFrame(alignment: Alignment.center, value: menuItems.first)
);
expect(menuRect.topLeft, buttonRect.topLeft);
expect(menuRect.topRight, buttonRect.topRight);
await popUpAndDown(
buildFrame(alignment: FractionalOffset.centerRight, value: menuItems.first)
buildFrame(alignment: Alignment.centerRight, value: menuItems.first)
);
expect(menuRect.topLeft, new Offset(800.0 - menuRect.width, buttonRect.top));
expect(menuRect.topRight, new Offset(800.0, buttonRect.top));
......@@ -487,19 +487,19 @@ void main() {
// so that it fits within the frame.
await popUpAndDown(
buildFrame(alignment: FractionalOffset.bottomLeft, value: menuItems.first)
buildFrame(alignment: Alignment.bottomLeft, value: menuItems.first)
);
expect(menuRect.bottomLeft, const Offset(0.0, 600.0));
expect(menuRect.bottomRight, new Offset(menuRect.width, 600.0));
await popUpAndDown(
buildFrame(alignment: FractionalOffset.bottomCenter, value: menuItems.first)
buildFrame(alignment: Alignment.bottomCenter, value: menuItems.first)
);
expect(menuRect.bottomLeft, new Offset(buttonRect.left, 600.0));
expect(menuRect.bottomRight, new Offset(buttonRect.right, 600.0));
await popUpAndDown(
buildFrame(alignment: FractionalOffset.bottomRight, value: menuItems.first)
buildFrame(alignment: Alignment.bottomRight, value: menuItems.first)
);
expect(menuRect.bottomLeft, new Offset(800.0 - menuRect.width, 600.0));
expect(menuRect.bottomRight, const Offset(800.0, 600.0));
......
......@@ -444,7 +444,7 @@ void main() {
await tester.pumpWidget(
new MaterialApp(
home: new Align(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
child: new SizedBox(
width: 300.0,
height: 200.0,
......
This diff is collapsed.
......@@ -205,7 +205,7 @@ void main() {
image: new SynchronousTestImageProvider(),
colorFilter: colorFilter,
fit: BoxFit.contain,
alignment: FractionalOffset.bottomLeft,
alignment: Alignment.bottomLeft,
centerSlice: new Rect.fromLTWH(10.0, 20.0, 30.0, 40.0),
repeat: ImageRepeat.repeatY,
);
......
......@@ -8,8 +8,8 @@ import 'package:flutter/painting.dart';
void main() {
test('LinearGradient scale test', () {
final LinearGradient testGradient = const LinearGradient(
begin: FractionalOffset.bottomRight,
end: const FractionalOffset(0.7, 1.0),
begin: Alignment.bottomRight,
end: const Alignment(0.7, 1.0),
colors: const <Color>[
const Color(0x00FFFFFF),
const Color(0x11777777),
......@@ -19,8 +19,8 @@ void main() {
final LinearGradient actual = LinearGradient.lerp(null, testGradient, 0.25);
expect(actual, const LinearGradient(
begin: FractionalOffset.bottomRight,
end: const FractionalOffset(0.7, 1.0),
begin: Alignment.bottomRight,
end: const Alignment(0.7, 1.0),
colors: const <Color>[
const Color(0x00FFFFFF),
const Color(0x04777777),
......@@ -31,8 +31,8 @@ void main() {
test('LinearGradient lerp test', () {
final LinearGradient testGradient1 = const LinearGradient(
begin: FractionalOffset.topLeft,
end: FractionalOffset.bottomLeft,
begin: Alignment.topLeft,
end: Alignment.bottomLeft,
colors: const <Color>[
const Color(0x33333333),
const Color(0x66666666),
......@@ -40,8 +40,8 @@ void main() {
);
final LinearGradient testGradient2 = const LinearGradient(
begin: FractionalOffset.topRight,
end: FractionalOffset.topLeft,
begin: Alignment.topRight,
end: Alignment.topLeft,
colors: const <Color>[
const Color(0x44444444),
const Color(0x88888888),
......@@ -50,8 +50,8 @@ void main() {
final LinearGradient actual = LinearGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const LinearGradient(
begin: const FractionalOffset(0.5, 0.0),
end: const FractionalOffset(0.0, 0.5),
begin: const Alignment(0.0, -1.0),
end: const Alignment(-1.0, 0.0),
colors: const <Color>[
const Color(0x3B3B3B3B),
const Color(0x77777777),
......@@ -62,24 +62,24 @@ void main() {
test('LinearGradient toString', () {
expect(
const LinearGradient(
begin: FractionalOffset.topLeft,
end: FractionalOffset.bottomLeft,
begin: Alignment.topLeft,
end: Alignment.bottomLeft,
colors: const <Color>[
const Color(0x33333333),
const Color(0x66666666),
],
).toString(),
equals(
'LinearGradient(FractionalOffset.topLeft, FractionalOffset.bottomLeft, [Color(0x33333333), Color(0x66666666)], null, TileMode.clamp)',
'LinearGradient(Alignment.topLeft, Alignment.bottomLeft, [Color(0x33333333), Color(0x66666666)], null, TileMode.clamp)',
),
);
});
test('LinearGradient with FractionalOffsetDirectional', () {
test('LinearGradient with AlignmentDirectional', () {
expect(
() {
return const LinearGradient(
begin: FractionalOffsetDirectional.topStart,
begin: AlignmentDirectional.topStart,
colors: const <Color>[ const Color(0xFFFFFFFF), const Color(0xFFFFFFFF) ]
).createShader(new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0));
},
......@@ -88,7 +88,7 @@ void main() {
expect(
() {
return const LinearGradient(
begin: FractionalOffsetDirectional.topStart,
begin: AlignmentDirectional.topStart,
colors: const <Color>[ const Color(0xFFFFFFFF), const Color(0xFFFFFFFF) ]
).createShader(new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0), textDirection: TextDirection.rtl);
},
......@@ -97,7 +97,7 @@ void main() {
expect(
() {
return const LinearGradient(
begin: FractionalOffsetDirectional.topStart,
begin: AlignmentDirectional.topStart,
colors: const <Color>[ const Color(0xFFFFFFFF), const Color(0xFFFFFFFF) ]
).createShader(new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0), textDirection: TextDirection.ltr);
},
......@@ -106,7 +106,7 @@ void main() {
expect(
() {
return const LinearGradient(
begin: FractionalOffset.topLeft,
begin: Alignment.topLeft,
colors: const <Color>[ const Color(0xFFFFFFFF), const Color(0xFFFFFFFF) ]
).createShader(new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0));
},
......@@ -114,11 +114,11 @@ void main() {
);
});
test('RadialGradient with FractionalOffsetDirectional', () {
test('RadialGradient with AlignmentDirectional', () {
expect(
() {
return const RadialGradient(
center: FractionalOffsetDirectional.topStart,
center: AlignmentDirectional.topStart,
colors: const <Color>[ const Color(0xFFFFFFFF), const Color(0xFFFFFFFF) ]
).createShader(new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0));
},
......@@ -127,7 +127,7 @@ void main() {
expect(
() {
return const RadialGradient(
center: FractionalOffsetDirectional.topStart,
center: AlignmentDirectional.topStart,
colors: const <Color>[ const Color(0xFFFFFFFF), const Color(0xFFFFFFFF) ]
).createShader(new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0), textDirection: TextDirection.rtl);
},
......@@ -136,7 +136,7 @@ void main() {
expect(
() {
return const RadialGradient(
center: FractionalOffsetDirectional.topStart,
center: AlignmentDirectional.topStart,
colors: const <Color>[ const Color(0xFFFFFFFF), const Color(0xFFFFFFFF) ]
).createShader(new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0), textDirection: TextDirection.ltr);
},
......@@ -145,7 +145,7 @@ void main() {
expect(
() {
return const RadialGradient(
center: FractionalOffset.topLeft,
center: Alignment.topLeft,
colors: const <Color>[ const Color(0xFFFFFFFF), const Color(0xFFFFFFFF) ]
).createShader(new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0));
},
......
......@@ -39,7 +39,7 @@ void main() {
rect: new Rect.fromLTWH(50.0, 75.0, 200.0, 100.0),
image: image,
fit: BoxFit.cover,
alignment: const FractionalOffset(0.0, 0.5)
alignment: const Alignment(-1.0, 0.0),
);
final Invocation command = canvas.invocations.firstWhere((Invocation invocation) {
......
......@@ -13,7 +13,7 @@ void main() {
RenderBaseline parent;
RenderSizedBox child;
final RenderBox root = new RenderPositionedBox(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
child: parent = new RenderBaseline(
baseline: 0.0,
baselineType: TextBaseline.alphabetic,
......
......@@ -14,7 +14,7 @@ void main() {
decoration: new BoxDecoration(
color: const Color(0xFF00FF00),
gradient: new RadialGradient(
center: FractionalOffset.topLeft, radius: 1.8,
center: Alignment.topLeft, radius: 1.8,
colors: <Color>[Colors.yellow[500], Colors.blue[500]],
),
boxShadow: kElevationToShadow[3],
......
......@@ -74,7 +74,7 @@ void main() {
' constraints: BoxConstraints(25.0<=w<=100.0, 25.0<=h<=100.0)\n'
' size: Size(25.0, 25.0)\n'
' image: [10×10]\n'
' alignment: FractionalOffset.center\n'
' alignment: Alignment.center\n'
),
);
......
......@@ -36,7 +36,7 @@ void main() {
' │ parentData: <none>\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n'
' │ alignment: FractionalOffset.center\n'
' │ alignment: Alignment.center\n'
' │ minWidth: 0.0\n'
' │ maxWidth: Infinity\n'
' │ minHeight: 0.0\n'
......@@ -122,7 +122,7 @@ void main() {
' │ parentData: <none>\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n'
' │ alignment: FractionalOffset.center\n'
' │ alignment: Alignment.center\n'
' │ minWidth: 10.0\n'
' │ maxWidth: 500.0\n'
' │ minHeight: 0.0\n'
......@@ -158,7 +158,7 @@ void main() {
' │ parentData: <none>\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n'
' │ alignment: FractionalOffset.center\n'
' │ alignment: Alignment.center\n'
' │ minWidth: 10.0\n'
' │ maxWidth: use parent maxWidth constraint\n'
' │ minHeight: use parent minHeight constraint\n'
......
......@@ -47,7 +47,7 @@ void main() {
RenderPositionedBox child;
final RealRoot root = new RealRoot(
child = new RenderPositionedBox(
alignment: FractionalOffset.center,
alignment: Alignment.center,
child: new RenderSizedBox(const Size(100.0, 100.0))
)
);
......
......@@ -23,9 +23,9 @@ void main() {
onPaint: () {
baseline1 = child.getDistanceToBaseline(TextBaseline.alphabetic);
height1 = text.size.height;
}
)
)
},
),
),
);
layout(root, phase: EnginePhase.paint);
......@@ -37,15 +37,15 @@ void main() {
textDirection: TextDirection.ltr,
),
maxHeight: height1 / 2.0,
alignment: const FractionalOffset(0.0, 0.0)
alignment: Alignment.topLeft,
),
painter: new TestCallbackPainter(
onPaint: () {
baseline2 = child.getDistanceToBaseline(TextBaseline.alphabetic);
height2 = text.size.height;
}
)
)
},
),
),
);
layout(root, phase: EnginePhase.paint);
......
......@@ -57,7 +57,7 @@ TestRenderingFlutterBinding get renderer {
/// has no build phase.
void layout(RenderBox box, {
BoxConstraints constraints,
FractionalOffset alignment: FractionalOffset.center,
Alignment alignment: Alignment.center,
EnginePhase phase: EnginePhase.layout,
}) {
assert(box != null); // If you want to just repump the last box, call pumpFrame().
......
......@@ -18,10 +18,10 @@ void main() {
RenderBox inner;
final RenderBox sizer = new RenderTransform(
transform: new Matrix4.identity(),
alignment: FractionalOffset.center,
alignment: Alignment.center,
child: inner = new RenderSizedBox(const Size(100.0, 100.0)),
);
layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: FractionalOffset.topLeft);
layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft);
expect(inner.globalToLocal(const Offset(0.0, 0.0)), equals(const Offset(0.0, 0.0)));
expect(inner.globalToLocal(const Offset(100.0, 100.0)), equals(const Offset(100.0, 100.0)));
expect(inner.globalToLocal(const Offset(25.0, 75.0)), equals(const Offset(25.0, 75.0)));
......@@ -36,13 +36,13 @@ void main() {
RenderBox inner;
final RenderBox sizer = new RenderTransform(
transform: new Matrix4.identity(),
alignment: FractionalOffset.center,
alignment: Alignment.center,
child: new RenderPadding(
padding: const EdgeInsets.only(left: 20.0),
child: inner = new RenderSizedBox(const Size(80.0, 100.0)),
),
);
layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: FractionalOffset.topLeft);
layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft);
expect(inner.globalToLocal(const Offset(0.0, 0.0)), equals(const Offset(-20.0, 0.0)));
expect(inner.globalToLocal(const Offset(100.0, 100.0)), equals(const Offset(80.0, 100.0)));
expect(inner.globalToLocal(const Offset(25.0, 75.0)), equals(const Offset(5.0, 75.0)));
......@@ -57,10 +57,10 @@ void main() {
RenderBox inner;
final RenderBox sizer = new RenderTransform(
transform: new Matrix4.translationValues(50.0, 200.0, 0.0),
alignment: FractionalOffset.center,
alignment: Alignment.center,
child: inner = new RenderSizedBox(const Size(100.0, 100.0)),
);
layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: FractionalOffset.topLeft);
layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft);
expect(inner.globalToLocal(const Offset(0.0, 0.0)), equals(const Offset(-50.0, -200.0)));
expect(inner.globalToLocal(const Offset(100.0, 100.0)), equals(const Offset(50.0, -100.0)));
expect(inner.globalToLocal(const Offset(25.0, 75.0)), equals(const Offset(-25.0, -125.0)));
......@@ -75,13 +75,13 @@ void main() {
RenderBox inner;
final RenderBox sizer = new RenderTransform(
transform: new Matrix4.translationValues(50.0, 200.0, 0.0),
alignment: FractionalOffset.center,
alignment: Alignment.center,
child: new RenderPadding(
padding: const EdgeInsets.only(left: 20.0),
child: inner = new RenderSizedBox(const Size(80.0, 100.0)),
),
);
layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: FractionalOffset.topLeft);
layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft);
expect(inner.globalToLocal(const Offset(0.0, 0.0)), equals(const Offset(-70.0, -200.0)));
expect(inner.globalToLocal(const Offset(100.0, 100.0)), equals(const Offset(30.0, -100.0)));
expect(inner.globalToLocal(const Offset(25.0, 75.0)), equals(const Offset(-45.0, -125.0)));
......@@ -96,10 +96,10 @@ void main() {
RenderBox inner;
final RenderBox sizer = new RenderTransform(
transform: new Matrix4.rotationZ(math.PI),
alignment: FractionalOffset.center,
alignment: Alignment.center,
child: inner = new RenderSizedBox(const Size(100.0, 100.0)),
);
layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: FractionalOffset.topLeft);
layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft);
expect(round(inner.globalToLocal(const Offset(0.0, 0.0))), equals(const Offset(100.0, 100.0)));
expect(round(inner.globalToLocal(const Offset(100.0, 100.0))), equals(const Offset(0.0, 0.0)));
expect(round(inner.globalToLocal(const Offset(25.0, 75.0))), equals(const Offset(75.0, 25.0)));
......@@ -114,13 +114,13 @@ void main() {
RenderBox inner;
final RenderBox sizer = new RenderTransform(
transform: new Matrix4.rotationZ(math.PI),
alignment: FractionalOffset.center,
alignment: Alignment.center,
child: new RenderPadding(
padding: const EdgeInsets.only(left: 20.0),
child: inner = new RenderSizedBox(const Size(80.0, 100.0)),
),
);
layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: FractionalOffset.topLeft);
layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft);
expect(round(inner.globalToLocal(const Offset(0.0, 0.0))), equals(const Offset(80.0, 100.0)));
expect(round(inner.globalToLocal(const Offset(100.0, 100.0))), equals(const Offset(-20.0, 0.0)));
expect(round(inner.globalToLocal(const Offset(25.0, 75.0))), equals(const Offset(55.0, 25.0)));
......@@ -135,10 +135,10 @@ void main() {
RenderBox inner;
final RenderBox sizer = new RenderTransform(
transform: rotateAroundXAxis(math.PI * 0.25), // at pi/4, we are about 70 pixels high
alignment: FractionalOffset.center,
alignment: Alignment.center,
child: inner = new RenderSizedBox(const Size(100.0, 100.0)),
);
layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: FractionalOffset.topLeft);
layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft);
expect(round(inner.globalToLocal(const Offset(25.0, 50.0))), equals(const Offset(25.0, 50.0)));
expect(inner.globalToLocal(const Offset(25.0, 17.0)).dy, greaterThan(0.0));
......@@ -152,10 +152,10 @@ void main() {
RenderBox inner;
final RenderBox sizer = new RenderTransform(
transform: rotateAroundXAxis(math.PI * 0.4999), // at pi/2, we're seeing the box on its edge,
alignment: FractionalOffset.center,
alignment: Alignment.center,
child: inner = new RenderSizedBox(const Size(100.0, 100.0)),
);
layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: FractionalOffset.topLeft);
layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft);
// the inner widget has a height of about half a pixel at this rotation, so
// everything should end up around the middle of the outer box.
......
......@@ -11,34 +11,34 @@ void main() {
await tester.pumpWidget(
new Align(
child: new Container(),
alignment: const FractionalOffset(0.75, 0.75),
alignment: const Alignment(0.50, 0.50),
),
);
await tester.pumpWidget(
new Align(
child: new Container(),
alignment: const FractionalOffset(0.5, 0.5),
alignment: const Alignment(0.0, 0.0),
),
);
await tester.pumpWidget(
const Align(
key: const GlobalObjectKey<Null>(null),
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
),
);
await tester.pumpWidget(const Directionality(
textDirection: TextDirection.rtl,
child: const Align(
key: const GlobalObjectKey<Null>(null),
alignment: FractionalOffsetDirectional.topStart,
alignment: AlignmentDirectional.topStart,
),
));
await tester.pumpWidget(
const Align(
key: const GlobalObjectKey<Null>(null),
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
),
);
});
......@@ -48,7 +48,7 @@ void main() {
textDirection: TextDirection.ltr,
child: new Align(
child: new Container(width: 100.0, height: 80.0),
alignment: FractionalOffsetDirectional.topStart,
alignment: AlignmentDirectional.topStart,
),
));
......@@ -59,7 +59,7 @@ void main() {
textDirection: TextDirection.ltr,
child: new Align(
child: new Container(width: 100.0, height: 80.0),
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
),
));
......@@ -72,7 +72,7 @@ void main() {
textDirection: TextDirection.rtl,
child: new Align(
child: new Container(width: 100.0, height: 80.0),
alignment: FractionalOffsetDirectional.topStart,
alignment: AlignmentDirectional.topStart,
),
));
......@@ -83,7 +83,7 @@ void main() {
textDirection: TextDirection.ltr,
child: new Align(
child: new Container(width: 100.0, height: 80.0),
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
),
));
......@@ -101,7 +101,7 @@ void main() {
width: 10.0,
height: 10.0
),
alignment: const FractionalOffset(0.50, 0.50),
alignment: const Alignment(0.0, 0.0),
),
),
);
......
......@@ -183,7 +183,7 @@ void main() {
textDirection: TextDirection.rtl,
child: new AnimatedContainer(
duration: const Duration(milliseconds: 200),
alignment: FractionalOffset.topRight,
alignment: Alignment.topRight,
child: new SizedBox(key: target, width: 100.0, height: 200.0),
),
),
......@@ -197,7 +197,7 @@ void main() {
textDirection: TextDirection.rtl,
child: new AnimatedContainer(
duration: const Duration(milliseconds: 200),
alignment: FractionalOffsetDirectional.bottomStart,
alignment: AlignmentDirectional.bottomStart,
child: new SizedBox(key: target, width: 100.0, height: 200.0),
),
),
......
......@@ -98,7 +98,7 @@ void main() {
textDirection: TextDirection.ltr,
child: new Center(
child: new AnimatedCrossFade(
alignment: FractionalOffset.bottomRight,
alignment: Alignment.bottomRight,
firstChild: new SizedBox(
key: firstKey,
width: 100.0,
......@@ -121,7 +121,7 @@ void main() {
textDirection: TextDirection.ltr,
child: new Center(
child: new AnimatedCrossFade(
alignment: FractionalOffset.bottomRight,
alignment: Alignment.bottomRight,
firstChild: new SizedBox(
key: firstKey,
width: 100.0,
......@@ -156,7 +156,7 @@ void main() {
textDirection: TextDirection.ltr,
child: new Center(
child: new AnimatedCrossFade(
alignment: FractionalOffsetDirectional.bottomEnd,
alignment: AlignmentDirectional.bottomEnd,
firstChild: new SizedBox(
key: firstKey,
width: 100.0,
......@@ -179,7 +179,7 @@ void main() {
textDirection: TextDirection.ltr,
child: new Center(
child: new AnimatedCrossFade(
alignment: FractionalOffsetDirectional.bottomEnd,
alignment: AlignmentDirectional.bottomEnd,
firstChild: new SizedBox(
key: firstKey,
width: 100.0,
......@@ -214,7 +214,7 @@ void main() {
textDirection: TextDirection.rtl,
child: new Center(
child: new AnimatedCrossFade(
alignment: FractionalOffsetDirectional.bottomEnd,
alignment: AlignmentDirectional.bottomEnd,
firstChild: new SizedBox(
key: firstKey,
width: 100.0,
......@@ -237,7 +237,7 @@ void main() {
textDirection: TextDirection.rtl,
child: new Center(
child: new AnimatedCrossFade(
alignment: FractionalOffsetDirectional.bottomEnd,
alignment: AlignmentDirectional.bottomEnd,
firstChild: new SizedBox(
key: firstKey,
width: 100.0,
......
......@@ -107,7 +107,7 @@ void main() {
testWidgets('ClipRect', (WidgetTester tester) async {
await tester.pumpWidget(
new Align(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
child: new SizedBox(
width: 100.0,
height: 100.0,
......@@ -131,7 +131,7 @@ void main() {
await tester.pumpWidget(
new Align(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
child: new SizedBox(
width: 100.0,
height: 100.0,
......@@ -149,7 +149,7 @@ void main() {
await tester.pumpWidget(
new Align(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
child: new SizedBox(
width: 200.0,
height: 200.0,
......@@ -167,7 +167,7 @@ void main() {
await tester.pumpWidget(
new Align(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
child: new SizedBox(
width: 200.0,
height: 200.0,
......@@ -185,7 +185,7 @@ void main() {
await tester.pumpWidget(
new Align(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
child: new SizedBox(
width: 200.0,
height: 200.0,
......@@ -203,7 +203,7 @@ void main() {
await tester.pumpWidget(
new Align(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
child: new SizedBox(
width: 200.0,
height: 200.0,
......
......@@ -10,7 +10,7 @@ import '../rendering/mock_canvas.dart';
void main() {
testWidgets('Container control test', (WidgetTester tester) async {
final Container container = new Container(
alignment: FractionalOffset.bottomRight,
alignment: Alignment.bottomRight,
padding: const EdgeInsets.all(7.0),
// uses color, not decoration:
color: const Color(0xFF00FF00),
......@@ -37,7 +37,7 @@ void main() {
expect(container, hasOneLineDescription);
await tester.pumpWidget(new Align(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
child: container
));
......@@ -96,7 +96,7 @@ void main() {
' │ parentData: offset=Offset(7.0, 7.0) (can use size)\n'
' │ constraints: BoxConstraints(w=39.0, h=64.0)\n'
' │ size: Size(39.0, 64.0)\n'
' │ alignment: FractionalOffset.bottomRight\n'
' │ alignment: Alignment.bottomRight\n'
' │ widthFactor: expand\n'
' │ heightFactor: expand\n'
' │\n'
......@@ -173,7 +173,7 @@ void main() {
' │ parentData: offset=Offset(7.0, 7.0) (can use size)\n'
' │ constraints: BoxConstraints(w=39.0, h=64.0)\n'
' │ size: Size(39.0, 64.0)\n'
' │ alignment: FractionalOffset.bottomRight\n'
' │ alignment: Alignment.bottomRight\n'
' │ widthFactor: expand\n'
' │ heightFactor: expand\n'
' │\n'
......@@ -281,7 +281,7 @@ void main() {
' │ layer: null\n'
' │ semantics node: null\n'
' │ size: Size(39.0, 64.0)\n'
' │ alignment: FractionalOffset.bottomRight\n'
' │ alignment: Alignment.bottomRight\n'
' │ textDirection: null\n'
' │ widthFactor: expand\n'
' │ heightFactor: expand\n'
......@@ -412,7 +412,7 @@ void main() {
' │ isBlockingSemanticsOfPreviouslyPaintedNodes: false\n'
' │ isSemanticBoundary: false\n'
' │ size: Size(39.0, 64.0)\n'
' │ alignment: FractionalOffset.bottomRight\n'
' │ alignment: Alignment.bottomRight\n'
' │ textDirection: null\n'
' │ widthFactor: expand\n'
' │ heightFactor: expand\n'
......
......@@ -14,7 +14,7 @@ void main() {
maxWidth: 100.0,
minHeight: 0.0,
maxHeight: 100.0,
alignment: const FractionalOffset(0.0, 0.0),
alignment: const Alignment(-1.0, -1.0),
child: new Center(
child: new FractionallySizedBox(
widthFactor: 0.5,
......
......@@ -312,7 +312,7 @@ void main() {
routes: <String, WidgetBuilder>{
'/next': (BuildContext context) {
return new Align(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
child: new Hero(
tag: 'foo',
child: new GestureDetector(
......
......@@ -49,7 +49,7 @@ void main() {
decoration: new BoxDecoration(
image: new DecorationImage(
image: new TestImageProvider(),
alignment: FractionalOffsetDirectional.topEnd,
alignment: AlignmentDirectional.topEnd,
repeat: ImageRepeat.repeatX,
matchTextDirection: true,
),
......@@ -88,7 +88,7 @@ void main() {
decoration: new BoxDecoration(
image: new DecorationImage(
image: new TestImageProvider(),
alignment: FractionalOffsetDirectional.topEnd,
alignment: AlignmentDirectional.topEnd,
repeat: ImageRepeat.repeatX,
matchTextDirection: true,
),
......@@ -124,7 +124,7 @@ void main() {
decoration: new BoxDecoration(
image: new DecorationImage(
image: new TestImageProvider(),
alignment: FractionalOffsetDirectional.topEnd,
alignment: AlignmentDirectional.topEnd,
repeat: ImageRepeat.repeatX,
),
),
......@@ -159,7 +159,7 @@ void main() {
decoration: new BoxDecoration(
image: new DecorationImage(
image: new TestImageProvider(),
alignment: FractionalOffsetDirectional.topEnd,
alignment: AlignmentDirectional.topEnd,
repeat: ImageRepeat.repeatX,
),
),
......@@ -194,7 +194,7 @@ void main() {
decoration: new BoxDecoration(
image: new DecorationImage(
image: new TestImageProvider(),
alignment: FractionalOffset.centerRight,
alignment: Alignment.centerRight,
matchTextDirection: true,
),
),
......@@ -226,7 +226,7 @@ void main() {
decoration: new BoxDecoration(
image: new DecorationImage(
image: new TestImageProvider(),
alignment: FractionalOffset.centerRight,
alignment: Alignment.centerRight,
),
),
),
......@@ -253,7 +253,7 @@ void main() {
decoration: new BoxDecoration(
image: new DecorationImage(
image: new TestImageProvider(),
alignment: FractionalOffset.centerRight,
alignment: Alignment.centerRight,
matchTextDirection: true
),
),
......@@ -281,7 +281,7 @@ void main() {
decoration: new BoxDecoration(
image: new DecorationImage(
image: new TestImageProvider(),
alignment: FractionalOffset.centerRight,
alignment: Alignment.centerRight,
matchTextDirection: true
),
),
......@@ -308,7 +308,7 @@ void main() {
height: 50.0,
child: new Image(
image: new TestImageProvider(),
alignment: FractionalOffsetDirectional.topEnd,
alignment: AlignmentDirectional.topEnd,
repeat: ImageRepeat.repeatX,
matchTextDirection: true,
),
......@@ -345,7 +345,7 @@ void main() {
height: 50.0,
child: new Image(
image: new TestImageProvider(),
alignment: FractionalOffsetDirectional.topEnd,
alignment: AlignmentDirectional.topEnd,
repeat: ImageRepeat.repeatX,
matchTextDirection: true,
),
......@@ -379,7 +379,7 @@ void main() {
height: 50.0,
child: new Image(
image: new TestImageProvider(),
alignment: FractionalOffsetDirectional.topEnd,
alignment: AlignmentDirectional.topEnd,
repeat: ImageRepeat.repeatX,
),
),
......@@ -412,7 +412,7 @@ void main() {
height: 50.0,
child: new Image(
image: new TestImageProvider(),
alignment: FractionalOffsetDirectional.topEnd,
alignment: AlignmentDirectional.topEnd,
repeat: ImageRepeat.repeatX,
),
),
......@@ -445,7 +445,7 @@ void main() {
height: 50.0,
child: new Image(
image: new TestImageProvider(),
alignment: FractionalOffset.centerRight,
alignment: Alignment.centerRight,
matchTextDirection: true,
),
),
......@@ -475,7 +475,7 @@ void main() {
height: 50.0,
child: new Image(
image: new TestImageProvider(),
alignment: FractionalOffset.centerRight,
alignment: Alignment.centerRight,
),
),
),
......@@ -500,7 +500,7 @@ void main() {
height: 50.0,
child: new Image(
image: new TestImageProvider(),
alignment: FractionalOffset.centerRight,
alignment: Alignment.centerRight,
matchTextDirection: true
),
),
......@@ -526,7 +526,7 @@ void main() {
height: 50.0,
child: new Image(
image: new TestImageProvider(),
alignment: FractionalOffset.centerRight,
alignment: Alignment.centerRight,
matchTextDirection: true
),
),
......@@ -548,7 +548,7 @@ void main() {
textDirection: TextDirection.ltr,
child: new Image(
image: new TestImageProvider(),
alignment: FractionalOffset.centerRight,
alignment: Alignment.centerRight,
matchTextDirection: false,
),
),
......@@ -560,7 +560,7 @@ void main() {
textDirection: TextDirection.ltr,
child: new Image(
image: new TestImageProvider(),
alignment: FractionalOffsetDirectional.centerEnd,
alignment: AlignmentDirectional.centerEnd,
matchTextDirection: true,
),
),
......@@ -572,7 +572,7 @@ void main() {
textDirection: TextDirection.ltr,
child: new Image(
image: new TestImageProvider(),
alignment: FractionalOffset.centerRight,
alignment: Alignment.centerRight,
matchTextDirection: false,
),
),
......
......@@ -10,7 +10,7 @@ void main() {
testWidgets('OverflowBox control test', (WidgetTester tester) async {
final GlobalKey inner = new GlobalKey();
await tester.pumpWidget(new Align(
alignment: const FractionalOffset(1.0, 1.0),
alignment: const Alignment(1.0, 1.0),
child: new SizedBox(
width: 10.0,
height: 20.0,
......@@ -42,7 +42,7 @@ void main() {
.where((DiagnosticsNode n) => !n.isFiltered(DiagnosticLevel.info))
.map((DiagnosticsNode n) => n.toString()).toList();
expect(description, <String>[
'alignment: FractionalOffset.center',
'alignment: Alignment.center',
'minWidth: 1.0',
'maxWidth: 2.0',
'minHeight: 3.0',
......
......@@ -46,7 +46,7 @@ void main() {
' ╎ │ size)\n'
' ╎ │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' ╎ │ size: Size(800.0, 600.0)\n'
' ╎ │ alignment: FractionalOffsetDirectional.topStart\n'
' ╎ │ alignment: AlignmentDirectional.topStart\n'
' ╎ │ textDirection: ltr\n'
' ╎ │ fit: expand\n'
' ╎ │ overflow: clip\n'
......@@ -113,7 +113,7 @@ void main() {
' ╎ │ size)\n'
' ╎ │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' ╎ │ size: Size(800.0, 600.0)\n'
' ╎ │ alignment: FractionalOffsetDirectional.topStart\n'
' ╎ │ alignment: AlignmentDirectional.topStart\n'
' ╎ │ textDirection: ltr\n'
' ╎ │ fit: expand\n'
' ╎ │ overflow: clip\n'
......
......@@ -9,8 +9,8 @@ import 'package:flutter/widgets.dart';
Shader createShader(Rect bounds) {
return new LinearGradient(
begin: FractionalOffset.topLeft,
end: FractionalOffset.bottomLeft,
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: <Color>[const Color(0x00FFFFFF), const Color(0xFFFFFFFF)],
stops: <double>[0.1, 0.35]
).createShader(bounds);
......@@ -31,7 +31,7 @@ void main() {
}
final Widget widget = new Align(
alignment: FractionalOffset.center,
alignment: Alignment.center,
child: new SizedBox(
width: 400.0,
height: 400.0,
......
......@@ -15,7 +15,7 @@ class TestItem extends StatelessWidget {
return new Container(
width: width,
height: height,
alignment: FractionalOffset.center,
alignment: Alignment.center,
child: new Text('Item $item', textDirection: TextDirection.ltr),
);
}
......
......@@ -41,7 +41,7 @@ void main() {
await tester.pumpWidget(
new Stack(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
children: <Widget>[
new Positioned(
left: 10.0,
......@@ -69,7 +69,7 @@ void main() {
await tester.pumpWidget(
new Stack(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
children: <Widget>[
new Positioned(
right: 10.0,
......@@ -140,7 +140,7 @@ void main() {
textDirection: TextDirection.ltr,
child: new Center(
child: new Stack(
alignment: FractionalOffset.center,
alignment: Alignment.center,
children: <Widget>[
new Container(key: child0Key, width: 20.0, height: 20.0),
new Container(key: child1Key, width: 10.0, height: 10.0),
......@@ -163,7 +163,7 @@ void main() {
textDirection: TextDirection.ltr,
child: new Center(
child: new Stack(
alignment: FractionalOffsetDirectional.bottomEnd,
alignment: AlignmentDirectional.bottomEnd,
children: <Widget>[
new Container(key: child0Key, width: 20.0, height: 20.0),
new Container(key: child1Key, width: 10.0, height: 10.0),
......@@ -186,7 +186,7 @@ void main() {
textDirection: TextDirection.rtl,
child: new Center(
child: new Stack(
alignment: FractionalOffset.center,
alignment: Alignment.center,
children: <Widget>[
new Container(key: child0Key, width: 20.0, height: 20.0),
new Container(key: child1Key, width: 10.0, height: 10.0),
......@@ -209,7 +209,7 @@ void main() {
textDirection: TextDirection.rtl,
child: new Center(
child: new Stack(
alignment: FractionalOffsetDirectional.bottomEnd,
alignment: AlignmentDirectional.bottomEnd,
children: <Widget>[
new Container(key: child0Key, width: 20.0, height: 20.0),
new Container(key: child1Key, width: 10.0, height: 10.0),
......@@ -257,7 +257,7 @@ void main() {
});
return new Center(
child: new IndexedStack(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
children: items,
index: index,
),
......@@ -289,7 +289,7 @@ void main() {
});
return new Center(
child: new IndexedStack(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
children: items,
key: key,
index: index,
......@@ -614,18 +614,18 @@ void main() {
testWidgets('Can change the text direction of a Stack', (WidgetTester tester) async {
await tester.pumpWidget(
new Stack(
alignment: FractionalOffset.center,
alignment: Alignment.center,
),
);
await tester.pumpWidget(
new Stack(
alignment: FractionalOffsetDirectional.topStart,
alignment: AlignmentDirectional.topStart,
textDirection: TextDirection.rtl,
),
);
await tester.pumpWidget(
new Stack(
alignment: FractionalOffset.center,
alignment: Alignment.center,
),
);
});
......
......@@ -82,7 +82,7 @@ void main() {
height: 100.0,
child: new Transform(
transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0),
alignment: const FractionalOffset(1.0, 0.5),
alignment: const Alignment(1.0, 0.0),
child: new GestureDetector(
onTap: () {
didReceiveTap = true;
......@@ -131,7 +131,7 @@ void main() {
child: new Transform(
transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0),
origin: const Offset(100.0, 0.0),
alignment: const FractionalOffset(0.0, 0.5),
alignment: const Alignment(-1.0, 0.0),
child: new GestureDetector(
onTap: () {
didReceiveTap = true;
......
......@@ -585,7 +585,7 @@ void main() {
testWidgets('Shrink-wrapping Wrap test', (WidgetTester tester) async {
await tester.pumpWidget(
new Align(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
child: new Wrap(
alignment: WrapAlignment.end,
crossAxisAlignment: WrapCrossAlignment.end,
......@@ -609,7 +609,7 @@ void main() {
await tester.pumpWidget(
new Align(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
child: new Wrap(
alignment: WrapAlignment.end,
crossAxisAlignment: WrapCrossAlignment.end,
......@@ -635,7 +635,7 @@ void main() {
testWidgets('Wrap spacing test', (WidgetTester tester) async {
await tester.pumpWidget(
new Align(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
child: new Wrap(
runSpacing: 10.0,
alignment: WrapAlignment.start,
......@@ -662,7 +662,7 @@ void main() {
testWidgets('Vertical Wrap test with spacing', (WidgetTester tester) async {
await tester.pumpWidget(
new Align(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
child: new Wrap(
direction: Axis.vertical,
spacing: 10.0,
......@@ -693,7 +693,7 @@ void main() {
await tester.pumpWidget(
new Align(
alignment: FractionalOffset.topLeft,
alignment: Alignment.topLeft,
child: new Wrap(
direction: Axis.horizontal,
spacing: 12.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