需要在两个行值之间添加空格


BlocBuilder<VoiceChatCubit, VoiceChatState>(
buildWhen: (previous, current) =>
previous.myClientRole != current.myClientRole,
builder: (context, state) {
return Row(
children: [
if (state.myClientRole == ClientRole.Broadcaster)
InkWell(
onTap: context.read<VoiceChatCubit>().toggleMute,
child: 
Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey,
offset: const Offset(
0,
3.0,
),
blurRadius: 1.0,
spreadRadius: 1.0,
),
],
color: Colors.white,
borderRadius: BorderRadius.circular(30),
border: Border.all(
color: border_color,
),
),

child:
Padding(
padding: const EdgeInsets.all(8.0),
child: BlocBuilder<VoiceChatCubit, VoiceChatState>(
buildWhen: (previous, current) =>
previous.canListen != current.canListen,
builder: (context, state) {
return Icon(
state.canListen
? Icons.volume_up
: Icons.volume_off,
color:
state.canListen ? Colors.black : Colors.red,
);
},
),
),
),
),
],
);
},
),

需要在这一行的两个值之间添加空格。尝试mainaxisalignment不起作用,也Space()以防我可以在两个值之间添加间距,但不知道在哪里添加它们。添加了整个行值:我尝试了主。轴的对齐并没有把它们分开,它们在这里是粘在一起的。

可以使用

Padding(padding: EdgeInsets.all(10)) 

要间隔出现。

可以试试下面的代码吗?

return  Container(
width: MediaQuery.of(context).size.width;
child:Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (state.myClientRole == ClientRole.Broadcaster)
InkWell(
onTap: context.read<VoiceChatCubit>().toggleMute,
child: 
Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey,
offset: const Offset(
0,
3.0,
),
blurRadius: 1.0,
spreadRadius: 1.0,
),

最新更新