You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

三星设备Flutter应用滚动时动态Container边框断裂问题求助

三星设备上AlignedGridView动态边框滚动断裂问题

在所有三星设备的商品页面中,我通过列表项的奇偶索引计算为Container设置动态边框,但上下滚动时,三星手机上的边框会出现断裂。设置静态全边框时功能正常,但我需要实现合并上下、左右边框并区分明暗的样式。使用的依赖包是flutter_staggered_grid_view: ^0.6.2。

相关代码

静态边框代码

decoration: BoxDecoration(border: Border.all(width: 0.5, color: Theme.of(context).dividerColor),color: Colors.transparent),

AlignedGridView实现代码

AlignedGridView.count(
  controller: _controller,
  primary: false,
  shrinkWrap: true,
  crossAxisCount: orientation == Orientation.portrait ? 2 : 4,
  mainAxisSpacing: 0,
  crossAxisSpacing: 0,
  itemCount: paginationProvider.photos.length,
  itemBuilder: (context, index) {

    final border1 = index.isEven
        ? Border(
      top: index == 0 || index == 1 ? border : BorderSide.none,
      left: border,
      right: border,
      bottom: border,
    )
    : Border(top: index == 0 || index == 1 ? border : BorderSide.none, right: border, bottom: border);

    buyNowLoaded.add(false);
    cartNowLoaded.add(false);
    wishlistLoader.add(false);

    specialPriceFoundCategoriesProduct.add("0.0");
    for(int i = 0 ; i < paginationProvider.photos[index].customAttributes!.length;i++)
    {
      if(paginationProvider.photos[index].customAttributes![i].attributeCode == 'special_price')
      {
        specialPriceFoundCategoriesProduct[index] = paginationProvider.photos[index].customAttributes![i].value;
        break;
      }
    }
    if (index == paginationProvider.photos.length) {
      return const Center(
        child: CircularProgressIndicator(),
      );
    }
    return Container(
      decoration:  BoxDecoration(border: border1),
      child: Container(),
    );
  },
),

内容的提问来源于stack exchange,提问作者Alpesh Kukadiya

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 09:57:21