Home > Back-end >  change hint Text position in Text field with expands in flutter
change hint Text position in Text field with expands in flutter

Time:11-09

I have Text field which will take a long message from the user and I set expands to True

the problem is the hint text is not at the beginning of the the line, How do I change its position ?

enter image description here

            SizedBox(
              height: 150,
              child: CustomTextField(
                enabledRadius: 7,
                focusedRadius: 7,
                expands: true,
                hintText: 'message',
                controller: messageController,
                textInputType: TextInputType.multiline,
              ),
            ),

CodePudding user response:

Thanks everyone, I figured it out by using

 textAlignVertical: TextAlignVertical(y: -1),

CodePudding user response:

You can use `textAlign:TextAlign.start` to align the hint

Here see the full code:

 SizedBox(
              height: 150,
              child: CustomTextField(
                enabledRadius: 7,
                focusedRadius: 7,
                expands: true,
                maxLines: null,
                textAlign: TextAlign.start,
                hintText: 'message',
                controller: messageController,
                textInputType: TextInputType.multiline,
              ),
            ),
  • Related