sách gpt4 ai đã đi

Flutter TextButton 填充

In lại 作者:行者123 更新时间:2023-12-04 10:54:19 36 4
mua khóa gpt4 Nike

随着 Flutter 2.0 的发布,FlatButton已被替换为 TextButton .
因此,填充属性不再直接可用,而是作为 ButtonStyle属性(property)。
我的问题是,我该如何设置它,因为它不再作为 EdgeInsets 可用?

TextButton(
style: new ButtonStyle(
padding: ???,
),
//padding: const EdgeInsets.all(0), //NOT AVAILABLE
child: Text("Support", style: Theme.of(context).textTheme.headline2),
onPressed: () => {Navigator.pushNamed(context, SupportScreen().routeName)},
),

1 Câu trả lời

这是我的 TextButton 代码

Container(
child: TextButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(Colors.green),
padding: MaterialStateProperty.all(
EdgeInsets.all(10)),
),
child: Text(
"Login",
style: TextStyle(
height: 1.0,
fontSize: 30,
color: Colors.white,
),
),
onPressed: () => {print("login")},
),
),
请参阅我使用 TextButton Widget 的 style 属性来插入填充和背景
对于两者我都使用了 MaterialStateProperty.all

关于Flutter TextButton 填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66476548/

36 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com