C.3. What about using an absolute position?

To specify an absolute position for a widget as x-y coordinates, nest it in a Positioned widget that is itself nested in a Stack widget. Positioned gives you access to properties like top, left, right, and bottom, similar to CSS. Here’s an example:

// Stack and Positioned
Stack(                            1
  children: [
    Positioned(                   2
      child: Text("Lorem ipsum"),
      left: 24.0,
      top: 24.0,
    ),
    Text("Not positioned"),       3
  ],
),

  • 1 All children of a Stack can be positioned.
  • 2 This widget is basically saying position:absolute in CSS.
  • 3 Any child of a stack that isn’t positioned is laid out like it would be in a Column (or Row if you change the main axis to horizontal).

For an in-depth look at Row and Column, read chapter 2. For an in-depth look at Positioned, check out chapter 4.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.28.9