[英]Row's children must not contain any null values, but a null value was found at index 2
I have the below screen image我有下面的屏幕图像
I have a Apple login in the ui so I need to use this Apple login in IOS only, so I create the below code:我在 ui 中有一个 Apple 登录,所以我只需要在 IOS 中使用这个 Apple 登录,所以我创建了以下代码:
Platform.isIOS
? IPetCustomCircleBtn(
constraintWidth:
constraints.maxWidth * 0.13,
constraintHeight:
constraints.maxHeight * 0.13,
iPetShapeBorder: CircleBorder(
side: BorderSide(
width: 2,
color: Colors.black,
style: BorderStyle.solid,
),
),
iPetChildCard: IPetCustomIcon(
ipFontIc: FontAwesomeIcons.apple,
colour: Colors.black,
),
iPetIconColor: Colors.black,
iPetFillColor: Colors.white,
)
: null
I found this error:我发现了这个错误:
Row's children must not contain any null values, but a null value was found at index 2
I tried to handle the problem by add an empty widget as the below code我试图通过添加一个空的小部件作为下面的代码来处理这个问题
Platform.isIOS
? IPetCustomCircleBtn(
constraintWidth:
constraints.maxWidth * 0.13,
constraintHeight:
constraints.maxHeight * 0.13,
iPetShapeBorder: CircleBorder(
side: BorderSide(
width: 2,
color: Colors.black,
style: BorderStyle.solid,
),
),
iPetChildCard: IPetCustomIcon(
ipFontIc: FontAwesomeIcons.apple,
colour: Colors.black,
),
iPetIconColor: Colors.black,
iPetFillColor: Colors.white,
)
: SizedBox()
but the problem the the look is not good as I need the rest of the buttons to be in the center of the row and this is my Full Row:但问题是外观不好,因为我需要按钮的 rest 位于行的中心,这是我的全行:
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
IPetCustomCircleBtn(
constraintWidth: constraints.maxWidth * 0.13,
constraintHeight: constraints.maxHeight * 0.13,
iPetShapeBorder: CircleBorder(),
iPetChildCard: IPetCustomIcon(
ipFontIc: FontAwesomeIcons.google,
colour: Colors.white,
),
iPetIconColor: Colors.white,
iPetFillColor: Colors.red,
),
IPetCustomCircleBtn(
constraintWidth: constraints.maxWidth * 0.13,
constraintHeight: constraints.maxHeight * 0.13,
iPetShapeBorder: CircleBorder(),
iPetChildCard: IPetCustomIcon(
ipFontIc: FontAwesomeIcons.facebook,
colour: Colors.white,
),
iPetIconColor: AppConst.kPrimaryWhiteBgColor,
iPetFillColor: AppConst.kBlueColor,
),
Platform.isIOS
? IPetCustomCircleBtn(
constraintWidth:
constraints.maxWidth * 0.13,
constraintHeight:
constraints.maxHeight * 0.13,
iPetShapeBorder: CircleBorder(
side: BorderSide(
width: 2,
color: Colors.black,
style: BorderStyle.solid,
),
),
iPetChildCard: IPetCustomIcon(
ipFontIc: FontAwesomeIcons.apple,
colour: Colors.black,
),
iPetIconColor: Colors.black,
iPetFillColor: Colors.white,
)
: SizedBox()
],
),
So there's any nice trick for this case:D..所以对于这种情况有什么好办法:D..
I hope this could be clear enough..我希望这可以足够清楚..
I recomend you build two rows, 1 with apple login and other without, then call Platform.isIOS? rowWithIos: rowWithoutIos
我建议你构建两行,1 行有苹果登录,其他没有,然后调用Platform.isIOS? rowWithIos: rowWithoutIos
Platform.isIOS? rowWithIos: rowWithoutIos
and if you build widgets for all login types you reduce the repeat code in this two rows. Platform.isIOS? rowWithIos: rowWithoutIos
,如果您为所有登录类型构建小部件,您可以减少这两行中的重复代码。
There are two ways I can think of:我能想到的方法有两种:
Try adding a height & width to your sizedBox尝试为您的sizedBox 添加高度和宽度
SizedBox(height: 0, width: 0,)
Experiment with尝试
Row( mainAxisAlignment: Platform.isIOS? MainAxisAlignment.spaceAround: MainAxisAlignment.spaceBetween....
You can replace mainAxisAlignment as your needs您可以根据需要替换 mainAxisAlignment
I found the better solution for this just make as the below code:我找到了更好的解决方案,就像下面的代码:
if (Platform.isIOS)
IPetCustomCircleBtn(
constraintWidth: constraints.maxWidth * 0.13,
constraintHeight: constraints.maxHeight * 0.13,
iPetShapeBorder: CircleBorder(
side: BorderSide(
width: 2,
color: Colors.black,
style: BorderStyle.solid,
),
),
iPetChildCard: IPetCustomIcon(
ipFontIc: FontAwesomeIcons.apple,
colour: Colors.black,
),
iPetIconColor: Colors.black,
iPetFillColor: Colors.white,
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.