Haikal Permana
Haikal Permana

Reputation: 867

Flutter - How to positioning widget under others?

I'm making layout inside the ListView with Stack widget, but the problem is the position. Everytime I add another widget, it's always started at the TopLeft. That's why i used Symmetrical Padding. At first, it still easy, but after three widgets, i feel it's really troublesome to use Symmetrical Padding with height more than 255.0

Padding(
  padding: const EdgeInsets.symmetric(vertical: 235.0)),

the layout

And, this is the short version of my layout code:

return AnimatedBuilder{
  builder: (BuildContext context, Widget child) {
      return Scaffold(
          //BODY
          body: ListView(
           children: <Widget>[
              new Container(
                 child: new Stack(
                   children: <Widget>[ 
                     //THE WIDGET
                      new Container(),
                      new Transform(),
                      new FadeTransition(),
                      new FadeTransition(),
                      new Text(),

Any help would greatly appreciated!

Upvotes: 1

Views: 4612

Answers (1)

anmol.majhail
anmol.majhail

Reputation: 51316

The Answer is in your Question Title - Use Positioned Widget for positioning widget under Stack

Now this Widget is Specifically Designed to use under Stack.

As Per Documentation:

A Positioned widget must be a descendant of a Stack, and the path from the Positioned widget to its enclosing Stack must contain only StatelessWidgets or StatefulWidgets (not other kinds of widgets, like RenderObjectWidgets).

If a widget is wrapped in a Positioned, then it is a positioned widget in its Stack. If the top property is non-null, the top edge of this child will be positioned top layout units from the top of the stack widget. The right, bottom, and left properties work analogously.

Upvotes: 2

Related Questions