[英]How to remove padding from TextButton and place it under widget Flutter
需要幫忙。 我想把文字Want to get your money?
和 TextButton Redeem
在按鈕611
(下面的屏幕截圖)下刪除所有填充。 我已經嘗試了很多方法,但最終將小部件放在按鈕本身下方並沒有奏效。 通過Flutter Inspector,可以看到上面還有一段距離,但是不明白怎么放在那里。 我將不勝感激。
身體
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Column(
children: [
const SizedBox(height: 24),
const TotalCoinsWidget(
coins: '611',
),
const RedeemButton(
textStyle: constants.Styles.smallBookTextStyleWhite,
buttonStyle: constants.Styles.smallMediumTextStyleWhite),
Padding(
padding: EdgeInsets.only(bottom: 50),
child: Text('Hello'),
)
],
),
);
文本按鈕
Widget build(BuildContext context) => Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Want to get your money?', style: textStyle),
TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
minimumSize: Size.zero,
),
onPressed: () {},
child: Text(
'Redeem',
style: buttonStyle,
),
),
],
);
TotalCoinsWidget
Widget build(BuildContext context) => Container(
alignment: Alignment.center,
width: _width,
height: _height,
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.circular(25),
boxShadow: [
BoxShadow(
color: color.withOpacity(0.5),
blurRadius: _blurRadius,
offset: Offset(_xOffset, _yOffset)),
],
),
child: Text(
coins,
style: textStyle,
),
);
您正在使用TextButton
小部件,如果您查看屬性style: TextButton.styleFrom(),
您會發現一個名為tapTargetSize
的屬性,默認情況下tapTargetSize
屬性使用MaterialTapTargetSize.padded
,要解決您的問題,您必須將tapTargetSize
屬性分配給MaterialTapTargetSize.shrinkWrap
將點擊目標尺寸縮小到最小尺寸。
“tapTargetSize:MaterialTapTargetSize.shrinkWrap”是不夠的。 添加“填充:EdgeInsets.zero”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.