leading: Padding(
padding:
const EdgeInsets.only(left: 45.0), // устанавливаем отступ слева
child: IconButton(
icon: const Icon(
Icons.menu,
color: Colors.white,
),
onPressed: () {},
),
),
actions: [
Padding(
padding: const EdgeInsets.only(
right: 45.0), // устанавливаем отступ справа
child: IconButton(
onPressed: () {},
icon: const Icon(Icons.notifications, color: Colors.white),
),
),
],
),
请帮忙解决这个问题。我将非常感激!
我尝试添加容器,但没有帮助。
那是因为 AppBar 小部件中的行距空间有限。您可以使用 Row 来对齐 AppBar 中的操作,如下所示:
AppBar(
automaticallyImplyLeading: false,
backgroundColor: Colors.black,
actions: [
SizedBox(
width: MediaQuery.of(context).size.width,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(
left: 45.0), // устанавливаем отступ слева
child: IconButton(
icon: const Icon(
Icons.menu,
color: Colors.white,
),
onPressed: () {
print('123');
},
),
),
Padding(
padding: const EdgeInsets.only(
right: 45.0), // устанавливаем отступ справа
child: IconButton(
onPressed: () {},
icon:
const Icon(Icons.notifications, color: Colors.white),
),
),
],
),
),
],
),
希望这会有所帮助