我如何居中文本字段的值(颤振)

时间:2019-12-05 21:29:13

标签: flutter textfield center

如何将文本字段的值居中(颤动)。这样,无论单词有多大,它始终位于中心?还有如何删除下划线栏?

new Container(

        alignment: Alignment(0.00 , 0.50),

       child: new TextField(                                 
    style: new TextStyle(
      fontSize: 40.0,
      height: 2.0,
      color: Colors.white                  
    )
  )

3 个答案:

答案 0 :(得分:1)

可以使用inputBorder.none删除边框。 TextAlign.center用于设置文本中心,但您必须使用inputDecoration.collapsed而不是inputDecoration。

import mysql.connector
import random
import string

def get_random_string(length):
  letters = string.ascii_letters
  result_str = ''.join(random.choice(letters) for i in range(length))
  return str(result_str)

username = get_random_string(12)
password = get_random_string(12)

mydb = mysql.connector.connect(
  host="localhost",
  user="root",
  password="root"
)

print(username)
print(password)

sql = 'CREATE USER "'+username+'"@"%" IDENTIFIED BY "'+password+'"';

mycursor = mydb.cursor()

mycursor.execute(sql)

答案 1 :(得分:0)

您可以使用decoration和textAlign属性,尝试下一个代码:

One Two 0 A d 1 B NaN 2 C b 3 NaN c 4 NaN NaN

答案 2 :(得分:0)

@Anton,您是否尝试过textAlign: TextAlign.center将下面的文字和装饰居中以删除下划线?

TextField(
  textAlign: TextAlign.center,
  style: new TextStyle(
    fontSize: 22.0, fontWeight: FontWeight.bold),
  decoration: new InputDecoration.collapsed(
    hintText: "Name",
  )
)

屏幕截图:

screenshot