BoxShadow显示在ScrollablePositionedList中其他小部件的上方

时间:2020-02-05 01:38:02

标签: flutter flutter-layout

我有Container作为ScrollablePositionedList项生成器的子级,并且Container有一些装饰和阴影。但是,框阴影显示在其他列表项上方。

我尝试使用ListView的生成器及其按预期方式工作,未在其他列表项上方显示框阴影。关于导致问题的原因有什么建议吗?

image

ScrollablePositionedList.builder(
itemCount: services.length,
itemBuilder: (context, index) {
  var service = services[index];
  return Container(
    padding:
        EdgeInsets.symmetric(horizontal: 30, vertical: 15),
    margin: EdgeInsets.symmetric(horizontal: 20, vertical: 5),
    decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.all(Radius.circular(15)),
        boxShadow: [
          BoxShadow(
              color: Color(0x1a000000),
              blurRadius: 20,
              spreadRadius: 0,
              offset: Offset(0, 10))
        ]),
    child: Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: <Widget>[
        SizedBox(
          width: 200,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Text(
                service.name,
                style: TextStyle(fontSize: 20),
              ),
              Text(
                service.description,
                style: TextStyle(fontSize: 12),
                overflow: TextOverflow.ellipsis,
                maxLines: 2,
              ),
            ],
          ),
        ),
        MaterialButton(
          minWidth: 0,
          child: Text('Edit'),
          onPressed: () {
            Navigator.push(
                context,
                MaterialPageRoute(
                    builder: (context) => AddServiceDetails(
                          serviceEdit: _serviceChanged,
                        )));
          },
          shape: new RoundedRectangleBorder(
              borderRadius: BorderRadius.all(
            Radius.circular(10),
          )),
          clipBehavior: Clip.antiAlias,
          textColor: Colors.teal,
        )
      ],
    ),
  );
}),

0 个答案:

没有答案