0

I want to align the (+,-) icons and TextField on same Vertical Position. But i'm not getting this. Here is My Code.

Row(
    crossAxisAlignment: CrossAxisAlignment.center,
    children: <Widget>[
             InkWell(
                  child: Icon(Icons.remove ,color: Colors.white),
                  onTap: (){},
                     ),
                     Container(
                               width: 35,
                               height: 40,
                               child: TextField(
                                      inputFormatters:[WhitelistingTextInputFormatter(RegExp(digit_Reg_Expression))],
                                      keyboardType: TextInputType.number,
                                      textAlign: TextAlign.center,
                                      cursorColor: Colors.green,
                                      controller: Controler_size[index],
                                               ),
                              ),
                                      InkWell(
                                              child: Icon(Icons.add,color: Colors.white),
                                              onTap: (){},
                                             )
                      ],
)

Please Help me to position these Widgets Vertically so that they align in the same vertical position.enter image description here

1
  • try Column instead of Row. let me know do you want that or something else. Commented May 4, 2020 at 9:38

3 Answers 3

1

If you want to place elements vertically, use the Column widget. If you want to place elements horizontally use the Row widget.

Check the code below: It works perfectly:

Column(
    crossAxisAlignment: CrossAxisAlignment.center,
    children: <Widget>[
             InkWell(
                  child: Icon(Icons.remove ,color: Colors.white),
                  onTap: (){},
                     ),
                     Container(
                               width: 35,
                               height: 40,
                               child: TextField(
                                      inputFormatters:[WhitelistingTextInputFormatter(RegExp(digit_Reg_Expression))],
                                      keyboardType: TextInputType.number,
                                      textAlign: TextAlign.center,
                                      cursorColor: Colors.green,
                                      controller: Controler_size[index],
                                               ),
                              ),
                                      InkWell(
                                              child: Icon(Icons.add,color: Colors.white),
                                              onTap: (){},
                                             )
                      ],
)

I hope this helps.

Sign up to request clarification or add additional context in comments.

1 Comment

Please see the linked attached first to know what i actually want
0

I followed the link you attach in the question, I think the problem is at your Container which wraps the TextField:

Container(...
   width: 35,
  ---> remove this: (height: 40) ...
)

2 Comments

I removed height of container but still same issue
@HabiburRehman Another way, you may try to fix the height of (+) sign and (-) sign, set their height to 40, hope this can help
0

set mainAxisAlignment to MainAxisAlignment.center

2 Comments

Please see attached link first to know about my issue
i also tried it but using CrossAxisAlignment.end i solved my issue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.