Imam Rizky GANTENG
Imam Rizky GANTENG

Reputation: 77

how do i put word on top of new container on flutter

Hello i have some problem with my flutter design
i want to make a box with rounded border using container
and on the top of this box i want to make a text and text looks like this but when i wrote the code the text is cannot be up look like this

this is my code

                height: 440.0,
                color: Colors.transparent,
                child: new Container(
                  decoration: new BoxDecoration(
                      color: Colors.blue,
                      borderRadius: new BorderRadius.only(
                        topLeft: const Radius.circular(40.0),
                        topRight: const Radius.circular(40.0),
                      )),
                  child: new Center(
                    child: Padding(
                      padding: EdgeInsets.symmetric(vertical: 0),
                      child: Text('Email'),
                    ),
                  ),
                ),
              )

Upvotes: 1

Views: 172

Answers (2)

Saugat Jonchhen
Saugat Jonchhen

Reputation: 382

Try this:

 new Container(
      alignment: Alignment.topCenter,
      decoration: new BoxDecoration(
      color: Colors.blue,
      borderRadius: new BorderRadius.only(
        topLeft: const Radius.circular(40.0),
        topRight: const Radius.circular(40.0),
      ),
    ),

Upvotes: 1

Jahidul Islam
Jahidul Islam

Reputation: 12565

Just use Align for keeping always on head.

Container(
            decoration: new BoxDecoration(
                color: Colors.blue,
                borderRadius: new BorderRadius.only(
                  topLeft: const Radius.circular(40.0),
                  topRight: const Radius.circular(40.0),
                )),
            child: new Align(
              alignment: Alignment.topCenter,
              child: Padding(
                padding: EdgeInsets.symmetric(vertical: 0),
                child: Text('Email'),
              ),
            ),
          ),

output:

enter image description here

Upvotes: 2

Related Questions