我是 Flutter 的新手,想在下面send again的文本中創建一個按鈕。我怎樣才能做到這一點?感謝您對此的幫助。
Align(
alignment: Alignment.bottomLeft,
child: Text(
'send again ',
style: TextStyle(
height: 1.2,
fontFamily: 'Dubai',
fontSize: 13,
color: Colors.blue,
fontWeight: FontWeight.w500,
)
)
)
uj5u.com熱心網友回復:
您可以TextButton為此使用小部件
TextButton(
style: TextButton.styleFrom(
TextStyle(
height: 1.2,
fontFamily: 'Dubai',
fontSize: 13,
color: Colors.blue,
fontWeight: FontWeight.w500,
),
),
onPressed: () {},
child: const Text('Send again'),
或者你可以Text用gestureDetector
Align(
alignment: Alignment.bottomLeft,
child: GestureDetector(
onTap: () {}
Text(
'send again ',
style: TextStyle(
height: 1.2,
fontFamily: 'Dubai',
fontSize: 13,
color: Colors.blue,
fontWeight: FontWeight.w500,
)
))
)
uj5u.com熱心網友回復:
Align(
alignment: Alignment.bottomLeft,
child: InkWell(
onTap: () {
// add action here whatever you want.
},
child: Text('send again ',
style: TextStyle(
height: 1.2,
fontFamily: 'Dubai',
fontSize: 13,
color: Colors.blue,
fontWeight: FontWeight.w500,
)
),
)
)
uj5u.com熱心網友回復:
在 Flutter 中,幾乎所有東西都是 Widget。這意味著即使是手勢檢測器也是一個小部件。
知道這一點,并且能夠創建一個Text小部件,您就已經到了目的地的一半。你只需Text要用 a 包裝你的小部件,TextButton它期望它的child屬性是 aWidget并且你可以提供你的小Text部件作為child.TextButton
這是 TextButton 的檔案,其中甚至包含一個非常好的視頻,介紹如何在 Flutter 中使用 TextButtons。
uj5u.com熱心網友回復:
這可能有效,
TextButton(
child: Text('send again'),
style: TextButton.styleFrom(
primary: Colors.teal,
onPrimary: Colors.white,
textStyle: TextStyle(
color: Colors.black,
fontSize: 40,
fontStyle: FontStyle.italic
),
),
onPressed: () {
print('Pressed');
},
)
uj5u.com熱心網友回復:
您可以使用 Flutter 中可用的按鈕,例如 MaterialButton、TextButton、ElevatedButton 等,也可以使用 InkWell 或 GestureDetector
Align(
alignment: Alignment.bottomLeft,
child: GestureDetector(
onTap: () {},
child: Text('send again ',
style: TextStyle(
height: 1.2,
fontFamily: 'Dubai',
fontSize: 13,
color: Colors.blue,
fontWeight: FontWeight.w500,
)),
))
Or
Align(
alignment: Alignment.bottomLeft,
child: InkWell(
onTap: () {},
child: Text('send again ',
style: TextStyle(
height: 1.2,
fontFamily: 'Dubai',
fontSize: 13,
color: Colors.blue,
fontWeight: FontWeight.w500,
)),
))
或者
Align(
alignment: Alignment.bottomLeft,
child: MaterialButton(
onPressed: (){},
child: Text('send again ',
style: TextStyle(
height: 1.2,
fontFamily: 'Dubai',
fontSize: 13,
color: Colors.blue,
fontWeight: FontWeight.w500,
)),
))
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/426597.html
