如何修复AnimatedList中的裁剪阴影?

时间:2019-06-11 11:58:42

标签: flutter flutter-layout flutter-animation

我使用AnimatedList,但在项目中使用阴影,我的项目如下面的代码,我需要一些帮助!

class TextSentMessage extends StatelessWidget {
  final String textMessage;
  final Widget buildStatus;

  TextSentMessage({this.textMessage, this.buildStatus});

  @override
  Widget build(BuildContext context) {
    print('message 4 : ' + textMessage);
    return Row(
      mainAxisAlignment: MainAxisAlignment.end,
      crossAxisAlignment: CrossAxisAlignment.end,
      children: <Widget>[
        Stack(
          overflow: Overflow.visible,
          children: <Widget>[
            Container(
                padding: EdgeInsets.only(
                    top: 10.0, bottom: 10.0, left: 20.0, right: 15.0),
                margin: EdgeInsets.all(5.0),
                constraints: BoxConstraints(
                    maxWidth: 0.7 * MediaQuery.of(context).size.width,
                    minWidth: 50.0),
                decoration: BoxDecoration(
                  color: Color.fromARGB(255, 0, 117, 255),
                  boxShadow: [
                    BoxShadow(
                        color: black_7, blurRadius: 64, offset: Offset(0, 7))
                  ],
                  borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(20),
                      topRight: Radius.circular(20),
                      bottomRight: Radius.circular(6),
                      bottomLeft: Radius.circular(20)),
                ),
                child: Text(textMessage,
                    textAlign: TextAlign.right,
                    style: TextStyle(
                        fontFamily: 'UTM Avo',
                        fontSize: 15.0,
                        color: Colors.white))),
          ],
        ),
        buildStatus
      ],
    );
  }
}

这是我使用的ListView.builder:https://i.imgur.com/4LVXOOw.jpg

这是我使用的AnimatedList:https://i.imgur.com/bQ3ocL1.jpg

1 个答案:

答案 0 :(得分:0)

我无法复制您的问题@quyen。

这是我在iOS模拟器和Flutter 1.5.4-hotfix.2(稳定通道)上所做的测试:

动画列表:      子代:AnimatedList(               initialItemCount:msgs.length,               itemBuilder:                   (BuildContext ctx,int索引,Animation动画){                 返回TextSentMessage(                   buildStatus:图标(                     Icons.check_circle,                     大小:18,                     颜色:Color.fromARGB(255,0,117,255),                   ),                   textMessage:msgs [index],                 );               },             ),

动画演示图片: animated list

“列表视图”构建器:

child: ListView.builder(
          itemBuilder: (ctx, index) {
            return TextSentMessage(
              buildStatus: Icon(
                Icons.check_circle,
                size: 18,
                color: Colors.green,
              ),
              textMessage: 'This is a text message!',
            );
          },
          itemCount: 6,
          scrollDirection: Axis.vertical,
        ),

LIST VIEW演示图像: list view