Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

Unable to Align widget Using Align() Flutter

i am new to flutter and i Need help with align widget Here have used alignment center for the TabBar widget and alignment bottomRight for Text widget and i didnt get the correct result here.

This is the Output image:

enter image description here

Source Code:

  Widget build(BuildContext context) {
    var screenSize = MediaQuery.of(context);
    return SafeArea(
      child: DefaultTabController(
        length: 2,
        child: Scaffold(
          backgroundColor: Colors.amber,
          body: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Align(
                *[**alignment: Alignment.bottomRight,**][1]*
                child: Text("data"),
              ),
              Align(
                ***alignment: Alignment.center,***
                child: ConstrainedBox(
                  constraints: BoxConstraints(
                    maxWidth: 300,
                    maxHeight: 60,
                  ),
                  child: AppBar(
                    automaticallyImplyLeading: false,
                    bottom: TabBar(
                      tabs: [
                        Tab(
                          icon: Icon(Icons.directions_bike),
                        ),
                        Tab(
                          icon: Icon(
                            Icons.directions_car,
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              ),
              ConstrainedBox(
                constraints: BoxConstraints(
                  maxHeight: 100,
                  maxWidth: 100,
                ),
                child: Container(
                  color: Colors.blue,
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
question from:https://stackoverflow.com/questions/65941855/unable-to-align-widget-using-align-flutter

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

1 Reply

0 votes
by (71.8m points)

For that please remove the mainAxisSize : MainAxisSize.min into the column widget.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...