繁体   English   中英

我无法使用 LinearPercentIndicator 类将 percent_indicator: ^4.2.2 包的“widgetIndicator:”居中

[英]I'm not able to center the 'widgetIndicator:' of the percent_indicator: ^4.2.2 package using the LinearPercentIndicator class

我注意到包使用“定位”来定位小部件,有什么办法解决这个问题吗?

在此处输入图像描述代码:

 LinearPercentIndicator(
          animateFromLastPercent: true,
          width: MediaQuery.of(context).size.width,
          animation: true,
          lineHeight: 20.0,
          animationDuration: 600,
          percent: valueIndicator == 0
              ? 1 / allCards!.length * (indexCard + 1)
              : valueIndicator,
          widgetIndicator: Text(
            '${indexCard + 1}',
            style: const TextStyle(fontWeight: FontWeight.bold),
          ),
          barRadius: const Radius.circular(10),
          curve: Curves.decelerate,
          progressColor: AppTheme.darkP3,
          backgroundColor: AppTheme.darkP2,
        ),

用容器包裹文本并根据需要添加边距

widgetIndicator: Container(
margin : EdgeInsets.only(top: 7),
child : Text(
            '${indexCard + 1}',
            style: const TextStyle(fontWeight: FontWeight.bold),
          ),
)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM