![]() My first child has position x: 5 and y: 5, and my second child has x: 80 and y: 25.” Second child: “OK, I wish to be 140 pixels wide, and 30 pixels tall.” Widget: “Hey second child, You must be from 0 to 290 wide, and 0 to 55 tall.” Widget: “Hmmm, since I want to put my second child below the first one, this leaves only 55 pixels of height for my second child.” Widget: “Hey first child, You must be from 0 to 290 pixels wide, and 0 to 75 tall.”įirst child: “OK, then I wish to be 290 pixels wide, and 20 pixels tall.” Widget: “Hmmm, since I want to have 5 pixels of padding, then my children can have at most 290 pixels of width and 75 pixels of height.” Parent: “You must be from 80 to 300 pixels wide, and 30 to 85 tall.” Widget: “Hey parent, what are my constraints?” The negotiation goes something like this: And, finally, the widget tells its parent about its own size (within the original constraints, of course).įor example, if a composed widget contains a column with some padding, and wants to lay out its two children as follows:.Then, the widget positions its children (horizontally in the x axis, and vertically in the y axis), one by one.One by one, the widget tells its children what their constraints are (which can be different for each child), and then asks each child what size it wants to be. Then the widget goes through its own list of children.A constraint is just a set of 4 doubles: a minimum and maximum width, and a minimum and maximum height. A widget gets its own constraints from its parent.Parent sets position.įlutter layout can’t really be understood without knowing the rule Constraints in Flutter Constraints go down. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |