我想更改 FloatingActionButton
的大小。但是,以下不接受 height
和 width
值。
floatingActionButton: FloatingActionButton(
backgroundColor: Color(0xff33333D),
onPressed: () {},
child: Icon(Icons.camera),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
我该如何调整?
答案 0 :(得分:1)
FloatingActionButton 大小在 Material Design 中定义:https://material.io/components/buttons-floating-action-button
您有两种尺寸:默认尺寸和迷你尺寸:
要定义一个迷你 FloatingActionButton,只需添加 .then((sentMessage) => {
sentMessage.react("✅");
message.delete({ timeout: 100 });
const filter = (reaction, user) => {
return !user.bot && ["✅"].includes(reaction.emoji.name);
};
sentMessage
.awaitReactions(filter, { max: 1 })
.then(async (collected) => {
const reaction = collected.first();
if (reaction.emoji.name === "✅") {
const userReacted = reaction.users.cache.find(
(user) => !user.bot
);
const member = await message.guild.members.fetch(userReacted);
setInterval(function(){ if (member.roles.cache.has("747217324851069004")) {
console.log(`Yay, the author of the message has the role!`);
} else {
reaction.users.remove(userReacted);
}
}, 0)
const command = message.author;
if (!member.roles.cache.has("747217324851069004")) return;
command.send("TEXT")
}
:
mini: true
现在,如果您想要其他尺寸,可以使用 floatingActionButton: FloatingActionButton(
backgroundColor: Color(0xff33333D),
mini: true,
onPressed: () {},
child: Icon(Icons.camera),
),
:
ElevatedButton
floatingActionButton: ConstrainedBox(
constraints: BoxConstraints.tightFor(width: 200, height: 200),
child: ElevatedButton(
child: Icon(Icons.camera, size: 160),
onPressed: () {},
style: ElevatedButton.styleFrom(
shape: CircleBorder(),
),
),
),
您会在这里找到定义圆形按钮的其他方法:https://www.kindacode.com/article/how-to-make-circular-buttons-in-flutter/