Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
215 views
in Technique[技术] by (71.8m points)

Align widgets without Stack in Flutter

I know how to align Widgets with Stack properly but I'm done using Stack because sometimes it gives me lots of headache when things become too messy. I would like to ask for that is there a way to stack widgets without using Stack? It is like Transform.translate can do the same thing but is there a more reliable way to do that?

            Container(
          height: 70.0,
          width: 70.0,
          decoration: BoxDecoration(
            gradient: bgDarkColorGradient,
            shape: BoxShape.circle,
            boxShadow: [
              BoxShadow(
                offset: Offset(0, 12),
                blurRadius: 24.0,
                spreadRadius: 0.0,
                color: Color.fromARGB(0, 0, 0, 130),
              ),
            ],
          ),
          child: Stack(
            children: [
              Positioned(
                child: Align(
                  alignment: Alignment.center,
                  child: Icon(
                    Icons.person_outline_outlined,
                    color: Colors.white,
                  ),
                ),
              ),
              Positioned(
                top: 35,
                right: 0,
                child: Align(
                  alignment: Alignment.bottomRight,
                  child: Container(
                    height: 32.0,
                    width: 32.0,
                    decoration: BoxDecoration(
                      shape: BoxShape.circle,
                      color: Colors.white,
                      border: Border.all(
                        width: 4.0,
                        color: Color.fromARGB(255, 77, 93, 144),
                      ),
                    ),
                    child: Icon(Icons.edit, size: 12.0),
                  ),
                ),
              ),
            ],
          ),
        ),

With this code, I almost achieved this output.The widget

Lastly, my question is that is there a way to get these kind of results without using Stack?

question from:https://stackoverflow.com/questions/65829398/align-widgets-without-stack-in-flutter

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...