當我向“TextButton”添加顏色時,會彈出一個錯誤。
未定義命名引數“顏色”。嘗試將名稱更正為現有命名引數的名稱或使用名稱“顏色”定義命名引數。
我該如何解決?下面的代碼行
Row(
children: <Widget>[
TextButton(
onPressed: () {},
child: Text('Entrar'),
color: Color(0xff7540ee).withOpacity(.2),
),
uj5u.com熱心網友回復:
替換此代碼
孩子:文本('Entrar'),顏色:顏色(0xff7540ee).withOpacity(.2),
對此
孩子:文本('Entrar',樣式:TextStyle(顏色(0xff7540ee).withOpacity(.2)),
uj5u.com熱心網友回復:
粘貼此代碼它將起作用。
Row(
children: <Widget>[
TextButton(
onPressed: () {},
child: Text('Entrar'),
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all(
Color(0xff7540ee).withOpacity(.2),
),
),
),
],
),
uj5u.com熱心網友回復:
如果你想改變文字顏色
Row(
children: <Widget>[
TextButton(
onPressed: (){},
child: Text('Entrar',
style: TextStyle(color: Colors.amber),
),
),
]
);
要么。
如果你想改變按鈕顏色
Row(
children: <Widget>[
Container(
color: Colors.amber,
child: TextButton(
onPressed: (){},
child: Text('Entrar',
style: TextStyle(color: Colors.amber),
),
),
),
]
);
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/453793.html
