Replace usage of FractionalOffset with Alignment (#12348)
Alignment will eventually replace FractionalOffset.
This commit is contained in:
parent
2b126bcd0d
commit
0044ea2dbb
@ -44,7 +44,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
return new Scaffold(
|
return new Scaffold(
|
||||||
body: new Stack(
|
body: new Stack(
|
||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
alignment: FractionalOffset.bottomCenter,
|
alignment: Alignment.bottomCenter,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new LayoutBuilder(
|
new LayoutBuilder(
|
||||||
builder: (BuildContext context, BoxConstraints constraints) {
|
builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
|
@ -224,7 +224,7 @@ class CardCollectionState extends State<CardCollection> {
|
|||||||
flexibleSpace: new Container(
|
flexibleSpace: new Container(
|
||||||
padding: const EdgeInsets.only(left: 72.0),
|
padding: const EdgeInsets.only(left: 72.0),
|
||||||
height: 128.0,
|
height: 128.0,
|
||||||
alignment: const FractionalOffset(0.0, 0.75),
|
alignment: const Alignment(-1.0, 0.5),
|
||||||
child: new Text('Swipe Away: ${_cardModels.length}', style: Theme.of(context).primaryTextTheme.title),
|
child: new Text('Swipe Away: ${_cardModels.length}', style: Theme.of(context).primaryTextTheme.title),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -330,8 +330,8 @@ class CardCollectionState extends State<CardCollection> {
|
|||||||
|
|
||||||
Shader _createShader(Rect bounds) {
|
Shader _createShader(Rect bounds) {
|
||||||
return new LinearGradient(
|
return new LinearGradient(
|
||||||
begin: FractionalOffset.topLeft,
|
begin: Alignment.topCenter,
|
||||||
end: FractionalOffset.bottomLeft,
|
end: Alignment.bottomCenter,
|
||||||
colors: <Color>[const Color(0x00FFFFFF), const Color(0xFFFFFFFF)],
|
colors: <Color>[const Color(0x00FFFFFF), const Color(0xFFFFFFFF)],
|
||||||
stops: <double>[0.1, 0.35],
|
stops: <double>[0.1, 0.35],
|
||||||
)
|
)
|
||||||
|
@ -64,8 +64,8 @@ class GradientRow extends StatelessWidget {
|
|||||||
height: 100.0,
|
height: 100.0,
|
||||||
decoration: new BoxDecoration(
|
decoration: new BoxDecoration(
|
||||||
gradient: new LinearGradient(
|
gradient: new LinearGradient(
|
||||||
begin: FractionalOffset.topLeft,
|
begin: Alignment.topLeft,
|
||||||
end: FractionalOffset.bottomRight,
|
end: Alignment.bottomRight,
|
||||||
colors: <Color>[ leftColor, rightColor ],
|
colors: <Color>[ leftColor, rightColor ],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -55,7 +55,7 @@ class _AppBarBottomSampleState extends State<AppBarBottomSample> with SingleTick
|
|||||||
data: Theme.of(context).copyWith(accentColor: Colors.white),
|
data: Theme.of(context).copyWith(accentColor: Colors.white),
|
||||||
child: new Container(
|
child: new Container(
|
||||||
height: 48.0,
|
height: 48.0,
|
||||||
alignment: FractionalOffset.center,
|
alignment: Alignment.center,
|
||||||
child: new TabPageSelector(controller: _tabController),
|
child: new TabPageSelector(controller: _tabController),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -169,7 +169,7 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate {
|
|||||||
this.selectedIndex,
|
this.selectedIndex,
|
||||||
});
|
});
|
||||||
|
|
||||||
final FractionalOffset translation;
|
final Alignment translation;
|
||||||
final double tColumnToRow;
|
final double tColumnToRow;
|
||||||
final double tCollapsed;
|
final double tCollapsed;
|
||||||
final int cardCount;
|
final int cardCount;
|
||||||
@ -349,7 +349,7 @@ class _AllSectionsView extends AnimatedWidget {
|
|||||||
|
|
||||||
return new CustomMultiChildLayout(
|
return new CustomMultiChildLayout(
|
||||||
delegate: new _AllSectionsLayout(
|
delegate: new _AllSectionsLayout(
|
||||||
translation: new FractionalOffset(selectedIndex.value - sectionIndex, 0.0),
|
translation: new Alignment((selectedIndex.value - sectionIndex) * 2.0 - 1.0, -1.0),
|
||||||
tColumnToRow: tColumnToRow,
|
tColumnToRow: tColumnToRow,
|
||||||
tCollapsed: tCollapsed,
|
tCollapsed: tCollapsed,
|
||||||
cardCount: sections.length,
|
cardCount: sections.length,
|
||||||
|
@ -25,8 +25,8 @@ class SectionCard extends StatelessWidget {
|
|||||||
decoration: new BoxDecoration(
|
decoration: new BoxDecoration(
|
||||||
borderRadius: new BorderRadius.circular(4.0),
|
borderRadius: new BorderRadius.circular(4.0),
|
||||||
gradient: new LinearGradient(
|
gradient: new LinearGradient(
|
||||||
begin: FractionalOffset.topLeft,
|
begin: Alignment.centerLeft,
|
||||||
end: FractionalOffset.topRight,
|
end: Alignment.centerRight,
|
||||||
colors: <Color>[
|
colors: <Color>[
|
||||||
section.leftColor,
|
section.leftColor,
|
||||||
section.rightColor,
|
section.rightColor,
|
||||||
@ -82,7 +82,7 @@ class SectionTitle extends StatelessWidget {
|
|||||||
opacity: opacity,
|
opacity: opacity,
|
||||||
child: new Transform(
|
child: new Transform(
|
||||||
transform: new Matrix4.identity()..scale(scale),
|
transform: new Matrix4.identity()..scale(scale),
|
||||||
alignment: FractionalOffset.center,
|
alignment: Alignment.center,
|
||||||
child: new Stack(
|
child: new Stack(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Positioned(
|
new Positioned(
|
||||||
@ -136,7 +136,7 @@ class SectionDetailView extends StatelessWidget {
|
|||||||
package: detail.imageAssetPackage,
|
package: detail.imageAssetPackage,
|
||||||
),
|
),
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
alignment: FractionalOffset.center,
|
alignment: Alignment.center,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -166,8 +166,8 @@ class ContactsDemoState extends State<ContactsDemo> {
|
|||||||
const DecoratedBox(
|
const DecoratedBox(
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
gradient: const LinearGradient(
|
gradient: const LinearGradient(
|
||||||
begin: const FractionalOffset(0.5, 0.0),
|
begin: const Alignment(0.0, -1.0),
|
||||||
end: const FractionalOffset(0.5, 0.30),
|
end: const Alignment(0.0, -0.4),
|
||||||
colors: const <Color>[const Color(0x60000000), const Color(0x00000000)],
|
colors: const <Color>[const Color(0x60000000), const Color(0x00000000)],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -39,7 +39,7 @@ class _CupertinoButtonDemoState extends State<CupertinoButtonsDemo> {
|
|||||||
: ' '),
|
: ' '),
|
||||||
const Padding(padding: const EdgeInsets.all(12.0)),
|
const Padding(padding: const EdgeInsets.all(12.0)),
|
||||||
new Align(
|
new Align(
|
||||||
alignment: const FractionalOffset(0.5, 0.4),
|
alignment: const Alignment(0.0, -0.2),
|
||||||
child: new Row(
|
child: new Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
@ -47,9 +47,9 @@ class NavigationIconView {
|
|||||||
return new FadeTransition(
|
return new FadeTransition(
|
||||||
opacity: _animation,
|
opacity: _animation,
|
||||||
child: new SlideTransition(
|
child: new SlideTransition(
|
||||||
position: new FractionalOffsetTween(
|
position: new AlignmentTween(
|
||||||
begin: const FractionalOffset(0.0, 0.02), // Small offset from the top.
|
begin: const Alignment(0.0, 0.4), // Slightly down.
|
||||||
end: FractionalOffset.topLeft,
|
end: Alignment.center,
|
||||||
).animate(_animation),
|
).animate(_animation),
|
||||||
child: new IconTheme(
|
child: new IconTheme(
|
||||||
data: new IconThemeData(
|
data: new IconThemeData(
|
||||||
|
@ -90,7 +90,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
|||||||
|
|
||||||
Widget buildRaisedButton() {
|
Widget buildRaisedButton() {
|
||||||
return new Align(
|
return new Align(
|
||||||
alignment: const FractionalOffset(0.5, 0.4),
|
alignment: const Alignment(0.0, -0.2),
|
||||||
child: new ButtonBar(
|
child: new ButtonBar(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@ -111,7 +111,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
|||||||
|
|
||||||
Widget buildFlatButton() {
|
Widget buildFlatButton() {
|
||||||
return new Align(
|
return new Align(
|
||||||
alignment: const FractionalOffset(0.5, 0.4),
|
alignment: const Alignment(0.0, -0.2),
|
||||||
child: new ButtonBar(
|
child: new ButtonBar(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@ -213,7 +213,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
|||||||
|
|
||||||
Widget buildIconButton() {
|
Widget buildIconButton() {
|
||||||
return new Align(
|
return new Align(
|
||||||
alignment: const FractionalOffset(0.5, 0.4),
|
alignment: const Alignment(0.0, -0.2),
|
||||||
child: new Row(
|
child: new Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@ -237,7 +237,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
|||||||
|
|
||||||
Widget buildActionButton() {
|
Widget buildActionButton() {
|
||||||
return new Align(
|
return new Align(
|
||||||
alignment: const FractionalOffset(0.5, 0.4),
|
alignment: const Alignment(0.0, -0.2),
|
||||||
child: new FloatingActionButton(
|
child: new FloatingActionButton(
|
||||||
child: const Icon(Icons.add),
|
child: const Icon(Icons.add),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
@ -85,7 +85,7 @@ class TravelDestinationItem extends StatelessWidget {
|
|||||||
right: 16.0,
|
right: 16.0,
|
||||||
child: new FittedBox(
|
child: new FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
alignment: FractionalOffset.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: new Text(destination.title,
|
child: new Text(destination.title,
|
||||||
style: titleStyle,
|
style: titleStyle,
|
||||||
),
|
),
|
||||||
|
@ -25,7 +25,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
|
|||||||
|
|
||||||
AnimationController _controller;
|
AnimationController _controller;
|
||||||
Animation<double> _drawerContentsOpacity;
|
Animation<double> _drawerContentsOpacity;
|
||||||
Animation<FractionalOffset> _drawerDetailsPosition;
|
Animation<Alignment> _drawerDetailsPosition;
|
||||||
bool _showDrawerContents = true;
|
bool _showDrawerContents = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -39,9 +39,9 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
|
|||||||
parent: new ReverseAnimation(_controller),
|
parent: new ReverseAnimation(_controller),
|
||||||
curve: Curves.fastOutSlowIn,
|
curve: Curves.fastOutSlowIn,
|
||||||
);
|
);
|
||||||
_drawerDetailsPosition = new FractionalOffsetTween(
|
_drawerDetailsPosition = new AlignmentTween(
|
||||||
begin: const FractionalOffset(0.0, -1.0),
|
begin: const Alignment(0.0, -2.0),
|
||||||
end: const FractionalOffset(0.0, 0.0),
|
end: Alignment.center,
|
||||||
).animate(new CurvedAnimation(
|
).animate(new CurvedAnimation(
|
||||||
parent: _controller,
|
parent: _controller,
|
||||||
curve: Curves.fastOutSlowIn,
|
curve: Curves.fastOutSlowIn,
|
||||||
@ -80,7 +80,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
|
|||||||
appBar: new AppBar(
|
appBar: new AppBar(
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(_backIcon()),
|
icon: new Icon(_backIcon()),
|
||||||
alignment: FractionalOffset.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
tooltip: 'Back',
|
tooltip: 'Back',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
@ -51,7 +51,7 @@ class DualHeaderWithHint extends StatelessWidget {
|
|||||||
margin: const EdgeInsets.only(left: 24.0),
|
margin: const EdgeInsets.only(left: 24.0),
|
||||||
child: new FittedBox(
|
child: new FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
alignment: FractionalOffset.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: new Text(
|
child: new Text(
|
||||||
name,
|
name,
|
||||||
style: textTheme.body1.copyWith(fontSize: 15.0),
|
style: textTheme.body1.copyWith(fontSize: 15.0),
|
||||||
|
@ -165,7 +165,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
|
|||||||
decoration: new BoxDecoration(
|
decoration: new BoxDecoration(
|
||||||
border: new Border(bottom: new BorderSide(color: theme.dividerColor))
|
border: new Border(bottom: new BorderSide(color: theme.dividerColor))
|
||||||
),
|
),
|
||||||
alignment: FractionalOffset.bottomLeft,
|
alignment: Alignment.bottomLeft,
|
||||||
child: new Text('Event name', style: theme.textTheme.display2)
|
child: new Text('Event name', style: theme.textTheme.display2)
|
||||||
),
|
),
|
||||||
new Container(
|
new Container(
|
||||||
@ -173,7 +173,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
|
|||||||
decoration: new BoxDecoration(
|
decoration: new BoxDecoration(
|
||||||
border: new Border(bottom: new BorderSide(color: theme.dividerColor))
|
border: new Border(bottom: new BorderSide(color: theme.dividerColor))
|
||||||
),
|
),
|
||||||
alignment: FractionalOffset.bottomLeft,
|
alignment: Alignment.bottomLeft,
|
||||||
child: new Text('Location', style: theme.textTheme.title.copyWith(color: Colors.black54))
|
child: new Text('Location', style: theme.textTheme.title.copyWith(color: Colors.black54))
|
||||||
),
|
),
|
||||||
new Column(
|
new Column(
|
||||||
|
@ -54,7 +54,7 @@ class _GridTitleText extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return new FittedBox(
|
return new FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
alignment: FractionalOffset.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: new Text(text),
|
child: new Text(text),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
|
|||||||
|
|
||||||
Widget buildCheckbox() {
|
Widget buildCheckbox() {
|
||||||
return new Align(
|
return new Align(
|
||||||
alignment: const FractionalOffset(0.5, 0.4),
|
alignment: const Alignment(0.0, -0.2),
|
||||||
child: new Column(
|
child: new Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@ -109,7 +109,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
|
|||||||
|
|
||||||
Widget buildRadio() {
|
Widget buildRadio() {
|
||||||
return new Align(
|
return new Align(
|
||||||
alignment: const FractionalOffset(0.5, 0.4),
|
alignment: const Alignment(0.0, -0.2),
|
||||||
child: new Column(
|
child: new Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@ -161,7 +161,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
|
|||||||
|
|
||||||
Widget buildSwitch() {
|
Widget buildSwitch() {
|
||||||
return new Align(
|
return new Align(
|
||||||
alignment: const FractionalOffset(0.5, 0.4),
|
alignment: const Alignment(0.0, -0.2),
|
||||||
child: new Row(
|
child: new Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
@ -107,8 +107,8 @@ class _CardDataItem extends StatelessWidget {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Align(
|
new Align(
|
||||||
alignment: page.id == 'L'
|
alignment: page.id == 'L'
|
||||||
? FractionalOffset.centerLeft
|
? Alignment.centerLeft
|
||||||
: FractionalOffset.centerRight,
|
: Alignment.centerRight,
|
||||||
child: new CircleAvatar(child: new Text('${page.id}')),
|
child: new CircleAvatar(child: new Text('${page.id}')),
|
||||||
),
|
),
|
||||||
new SizedBox(
|
new SizedBox(
|
||||||
|
@ -188,7 +188,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
|||||||
),
|
),
|
||||||
new Container(
|
new Container(
|
||||||
padding: const EdgeInsets.all(20.0),
|
padding: const EdgeInsets.all(20.0),
|
||||||
alignment: const FractionalOffset(0.5, 0.5),
|
alignment: Alignment.center,
|
||||||
child: new RaisedButton(
|
child: new RaisedButton(
|
||||||
child: const Text('SUBMIT'),
|
child: const Text('SUBMIT'),
|
||||||
onPressed: _handleSubmitted,
|
onPressed: _handleSubmitted,
|
||||||
|
@ -211,7 +211,7 @@ class _PestoLogoState extends State<PestoLogo> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return new Transform(
|
return new Transform(
|
||||||
transform: new Matrix4.identity()..scale(widget.height / kLogoHeight),
|
transform: new Matrix4.identity()..scale(widget.height / kLogoHeight),
|
||||||
alignment: FractionalOffset.topCenter,
|
alignment: Alignment.topCenter,
|
||||||
child: new SizedBox(
|
child: new SizedBox(
|
||||||
width: kLogoWidth,
|
width: kLogoWidth,
|
||||||
child: new Stack(
|
child: new Stack(
|
||||||
@ -362,8 +362,8 @@ class _RecipePageState extends State<RecipePage> {
|
|||||||
background: new DecoratedBox(
|
background: new DecoratedBox(
|
||||||
decoration: new BoxDecoration(
|
decoration: new BoxDecoration(
|
||||||
gradient: new LinearGradient(
|
gradient: new LinearGradient(
|
||||||
begin: const FractionalOffset(0.5, 0.0),
|
begin: const Alignment(0.0, -1.0),
|
||||||
end: const FractionalOffset(0.5, 0.40),
|
end: const Alignment(0.0, -0.2),
|
||||||
colors: <Color>[const Color(0x60000000), const Color(0x00000000)],
|
colors: <Color>[const Color(0x60000000), const Color(0x00000000)],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -450,7 +450,7 @@ class RecipeSheet extends StatelessWidget {
|
|||||||
package: recipe.ingredientsImagePackage,
|
package: recipe.ingredientsImagePackage,
|
||||||
width: 32.0,
|
width: 32.0,
|
||||||
height: 32.0,
|
height: 32.0,
|
||||||
alignment: FractionalOffset.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
fit: BoxFit.scaleDown
|
fit: BoxFit.scaleDown
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -320,7 +320,7 @@ class _ProductItem extends StatelessWidget {
|
|||||||
new Column(
|
new Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Align(
|
new Align(
|
||||||
alignment: FractionalOffset.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: new _ProductPriceItem(product: product),
|
child: new _ProductPriceItem(product: product),
|
||||||
),
|
),
|
||||||
new Container(
|
new Container(
|
||||||
|
@ -85,7 +85,7 @@ class _VendorItem extends StatelessWidget {
|
|||||||
new SizedBox(
|
new SizedBox(
|
||||||
height: 24.0,
|
height: 24.0,
|
||||||
child: new Align(
|
child: new Align(
|
||||||
alignment: FractionalOffset.bottomLeft,
|
alignment: Alignment.bottomLeft,
|
||||||
child: new Text(vendor.name, style: theme.vendorTitleStyle),
|
child: new Text(vendor.name, style: theme.vendorTitleStyle),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -174,7 +174,7 @@ class _Heading extends StatelessWidget {
|
|||||||
product.imageAsset,
|
product.imageAsset,
|
||||||
package: product.imageAssetPackage,
|
package: product.imageAssetPackage,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
alignment: FractionalOffset.center,
|
alignment: Alignment.center,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -138,7 +138,7 @@ class GalleryHomeState extends State<GalleryHome> with SingleTickerProviderState
|
|||||||
child: new Container(
|
child: new Container(
|
||||||
height: 48.0,
|
height: 48.0,
|
||||||
padding: const EdgeInsets.only(left: 16.0),
|
padding: const EdgeInsets.only(left: 16.0),
|
||||||
alignment: FractionalOffset.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: new Text(galleryItem.category, style: headerStyle)
|
child: new Text(galleryItem.category, style: headerStyle)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -13,7 +13,7 @@ void main() {
|
|||||||
// The root of our render tree is a RenderPositionedBox, which centers its
|
// The root of our render tree is a RenderPositionedBox, which centers its
|
||||||
// child both vertically and horizontally.
|
// child both vertically and horizontally.
|
||||||
root: new RenderPositionedBox(
|
root: new RenderPositionedBox(
|
||||||
alignment: FractionalOffset.center,
|
alignment: Alignment.center,
|
||||||
// We use a RenderParagraph to display the text 'Hello, world.' without
|
// We use a RenderParagraph to display the text 'Hello, world.' without
|
||||||
// any explicit styling.
|
// any explicit styling.
|
||||||
child: new RenderParagraph(
|
child: new RenderParagraph(
|
||||||
|
@ -34,12 +34,12 @@ void main() {
|
|||||||
// spin.
|
// spin.
|
||||||
final RenderTransform spin = new RenderTransform(
|
final RenderTransform spin = new RenderTransform(
|
||||||
transform: new Matrix4.identity(),
|
transform: new Matrix4.identity(),
|
||||||
alignment: FractionalOffset.center,
|
alignment: Alignment.center,
|
||||||
child: square
|
child: square
|
||||||
);
|
);
|
||||||
// Finally, we center the spinning green square...
|
// Finally, we center the spinning green square...
|
||||||
final RenderBox root = new RenderPositionedBox(
|
final RenderBox root = new RenderPositionedBox(
|
||||||
alignment: FractionalOffset.center,
|
alignment: Alignment.center,
|
||||||
child: spin
|
child: spin
|
||||||
);
|
);
|
||||||
// and attach it to the window.
|
// and attach it to the window.
|
||||||
|
@ -100,7 +100,7 @@ void main() {
|
|||||||
flexRoot.add(proxy);
|
flexRoot.add(proxy);
|
||||||
addFlexChildSolidColor(flexRoot, const Color(0xFF0000FF), flex: 1);
|
addFlexChildSolidColor(flexRoot, const Color(0xFF0000FF), flex: 1);
|
||||||
|
|
||||||
transformBox = new RenderTransform(child: flexRoot, transform: new Matrix4.identity(), alignment: FractionalOffset.center);
|
transformBox = new RenderTransform(child: flexRoot, transform: new Matrix4.identity(), alignment: Alignment.center);
|
||||||
final RenderPadding root = new RenderPadding(padding: const EdgeInsets.all(80.0), child: transformBox);
|
final RenderPadding root = new RenderPadding(padding: const EdgeInsets.all(80.0), child: transformBox);
|
||||||
|
|
||||||
binding.renderView.child = root;
|
binding.renderView.child = root;
|
||||||
|
@ -14,14 +14,14 @@ void approxExpect(Alignment a, Alignment b) {
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('Alignment control test', () {
|
test('Alignment control test', () {
|
||||||
const Alignment offset = const Alignment(0.5, 0.25);
|
const Alignment alignment = const Alignment(0.5, 0.25);
|
||||||
|
|
||||||
expect(offset, hasOneLineDescription);
|
expect(alignment, hasOneLineDescription);
|
||||||
expect(offset.hashCode, equals(const Alignment(0.5, 0.25).hashCode));
|
expect(alignment.hashCode, equals(const Alignment(0.5, 0.25).hashCode));
|
||||||
|
|
||||||
expect(offset / 2.0, const Alignment(0.25, 0.125));
|
expect(alignment / 2.0, const Alignment(0.25, 0.125));
|
||||||
expect(offset ~/ 2.0, const Alignment(0.0, 0.0));
|
expect(alignment ~/ 2.0, const Alignment(0.0, 0.0));
|
||||||
expect(offset % 5.0, const Alignment(0.5, 0.25));
|
expect(alignment % 5.0, const Alignment(0.5, 0.25));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Alignment.lerp()', () {
|
test('Alignment.lerp()', () {
|
||||||
|
@ -290,7 +290,7 @@ abstract class Finder {
|
|||||||
///
|
///
|
||||||
/// The [at] parameter specifies the location relative to the size of the
|
/// The [at] parameter specifies the location relative to the size of the
|
||||||
/// target element where the hit test is performed.
|
/// target element where the hit test is performed.
|
||||||
Finder hitTestable({ FractionalOffset at: FractionalOffset.center }) => new _HitTestableFinder(this, at);
|
Finder hitTestable({ Alignment at: Alignment.center }) => new _HitTestableFinder(this, at);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -336,10 +336,10 @@ class _LastFinder extends Finder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _HitTestableFinder extends Finder {
|
class _HitTestableFinder extends Finder {
|
||||||
_HitTestableFinder(this.parent, this.offset);
|
_HitTestableFinder(this.parent, this.alignment);
|
||||||
|
|
||||||
final Finder parent;
|
final Finder parent;
|
||||||
final FractionalOffset offset;
|
final Alignment alignment;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get description => '${parent.description} (considering only hit-testable ones)';
|
String get description => '${parent.description} (considering only hit-testable ones)';
|
||||||
@ -349,7 +349,7 @@ class _HitTestableFinder extends Finder {
|
|||||||
for (final Element candidate in parent.apply(candidates)) {
|
for (final Element candidate in parent.apply(candidates)) {
|
||||||
final RenderBox box = candidate.renderObject;
|
final RenderBox box = candidate.renderObject;
|
||||||
assert(box != null);
|
assert(box != null);
|
||||||
final Offset absoluteOffset = box.localToGlobal(offset.alongSize(box.size));
|
final Offset absoluteOffset = box.localToGlobal(alignment.alongSize(box.size));
|
||||||
final HitTestResult hitResult = new HitTestResult();
|
final HitTestResult hitResult = new HitTestResult();
|
||||||
WidgetsBinding.instance.hitTest(hitResult, absoluteOffset);
|
WidgetsBinding.instance.hitTest(hitResult, absoluteOffset);
|
||||||
for (final HitTestEntry entry in hitResult.path) {
|
for (final HitTestEntry entry in hitResult.path) {
|
||||||
|
@ -29,7 +29,7 @@ void main() {
|
|||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
expect(find.byType(GestureDetector), findsNWidgets(2));
|
expect(find.byType(GestureDetector), findsNWidgets(2));
|
||||||
final Finder hitTestable = find.byType(GestureDetector).hitTestable(at: const FractionalOffset(0.5, 0.5));
|
final Finder hitTestable = find.byType(GestureDetector).hitTestable(at: Alignment.center);
|
||||||
expect(hitTestable, findsOneWidget);
|
expect(hitTestable, findsOneWidget);
|
||||||
expect(tester.widget(hitTestable).key, const ValueKey<int>(0));
|
expect(tester.widget(hitTestable).key, const ValueKey<int>(0));
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user