简体   繁体   English

行的子项不得包含任何 null 值,但在索引 2 处找到 null 值

[英]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:我能想到的方法有两种:

  1. Try adding a height & width to your sizedBox尝试为您的sizedBox 添加高度和宽度

     SizedBox(height: 0, width: 0,)
  2. 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.

相关问题 OOP 错误行的子项不得包含任何 null 值,但在索引 0 处找到了 null 值 - OOP Error Row's children must not contain any null values, but a null value was found at index 0 如何解决 Flutter 错误列的子项不得包含任何 null 值,但在索引 0 处找到 null 值? - How to solve Flutter error Column's children must not contain any null values, but a null value was found at index 0? Flutter 错误列的子项不得包含任何 null 值,但在索引 0 处找到 null 值 - Flutter error Column's children must not contain any null values, but a null value was found at index 0 Flutter 错误:列的子项不得包含任何 null 值,但在索引 0 处找到 null 值 - Flutter error: Column's children must not contain any null values, but a null value was found at index 0 Flutter 函数错误:列的子项不得包含任何空值,但在索引 1 处发现空值 - Flutter function error: Column's children must not contain any null values, but a null value was found at index 1 列的子项不得包含任何 null 值,但在索引 13 处找到 null 值。 Flutter Z866408593C2F8BDF27 - Column's children must not contain any null values, but a null value was found at index 13. Flutter Function 列的子项不得包含任何 null 值,但在索引 0 处找到 null 值 - Column's children must not contain any null values, but null value was found at index 0 行的孩子不得包含任何 Null 值 Flutter 错误 - Row's Children Must Not Contain Any Null Values Flutter Error 未处理的异常:无效参数(值):不得为 null Flutter 2 - Unhandled Exception: Invalid argument(s) (value): Must not be null Flutter 2 Flutter 未处理的异常:无效参数(值):不得为 null - Flutter Unhandled Exception: Invalid argument(s) (value): Must not be null
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM