Skip to content

Flutter: Is the official documentation for align wrong? #68680

@LuodiJackShen

Description

@LuodiJackShen

When I was reading through Align's documentation I found the following explanation.

enter image description here

The link is https://api.flutter.dev/flutter/widgets/Align-class.html#widgets.Align.2

The 0.2 is the xAlign and the 0.6 is the YAlign, follow the formulas in the official documentation and finally calculate a point (36.0,48.0). When xAlign is less than zero or yAlign is less than zero, the calculation according to this formula is always positive. And the formula for calculating the offset of FlutterLogo and Container in the source code is as follows(alignment.dart lines:290):

Offset other = size - child!.size as Offset;
final double centerX = other.dx / 2.0;
final double centerY = other.dy / 2.0;
childParentData.offset = Offset(centerX + xAlign * centerX, centerY + yAlign * centerY);

The result according to the formula in the source code does not seem to have any relation to (36,48). Did I misunderstand or did the document say something wrong?

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listd: api docsIssues with https://api.flutter.dev/d: examplesSample code and demosframeworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions