ListView崩溃,异常:'child.hasSize':不正确

时间:2019-07-14 21:57:51

标签: flutter dart

我有一个ListView,在几次滚动后向上滚动时会崩溃。我不太确定是什么原因导致了我的代码。非常感谢有人向我指出。谢谢。

代码如下:

return AnimatedContainer(
  duration: Duration(milliseconds: 500),
  curve: Curves.fastOutSlowIn,
  child: Padding(
    padding: EdgeInsets.only(
        right: hp(2),
        left: hp(2),
        top: hp(0),
        bottom: hp(2)),
    child: Row(
      crossAxisAlignment:
          CrossAxisAlignment.start,
      children: <Widget>[
        Expanded(
          child: Padding(
            padding: EdgeInsets.only(
                right: wp(2.5)),
            child: Column(
              children: <Widget>[
                Align(
                  alignment:
                      Alignment.centerRight,
                  child: Padding(
                    padding:
                        EdgeInsets.only(
                            bottom:
                                hp(0.5)),
                    child: Text(
                      m['sender']
                          .toString(),
                      style: TextStyle(
                          fontSize: wp(4),
                          color:
                              Colors.white,
                          fontWeight:
                              FontWeight
                                  .bold),
                    ),
                  ),
                ),
                Flexible(
                  fit: FlexFit.tight,
                  flex: 0,
                  child: Align(
                    alignment: Alignment
                        .centerRight,
                    child: Container(
                      decoration:
                          ShapeDecoration(
                        color: Colors.white,
                        shape: RoundedRectangleBorder(
                            borderRadius:
                                BorderRadius
                                    .circular(
                                        12.5)),
                      ),
                      child: Padding(
                        padding:
                            EdgeInsets.all(
                                hp(1)),
                        child: Text(
                          m['message']
                              .toString(),
                          style: TextStyle(
                              fontSize:
                                  wp(3.5),
                              color: Colors
                                  .black,
                              fontWeight:
                                  FontWeight
                                      .normal),
                        ),
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ],
    ),
  ),
);

0 个答案:

没有答案