簡體   English   中英

[Flutter Error]-讓線性進度指示器響應式

[英][Flutter Error]-Making Linear Progress Indicator Responsive

所以我創建了一張卡片,其中包含課程的某些信息,它顯示了您使用 LinearProgressIndicator 完成的課程的百分比。

Widget top(BuildContext context) {
return Row(
  children: <Widget>[
    Image.network(
      image,
      height: 100,
      width: 100,
    ),
    SizedBox(
      width: 16,
    ),
    Flexible(
        child: Column(
      mainAxisSize: MainAxisSize.min,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        Text(checkTitle(title),
            style: Theme.of(context).textTheme.headline3),
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            SizedBox(
              width: MediaQuery.of(context).size.width * 0.5,
              child: LinearProgressIndicator(
                value: int.parse(progress) * 0.01,
                valueColor: AlwaysStoppedAnimation<Color>(LightSeaGreen),
                backgroundColor: Colors.greenAccent,

                // (int.parse(progress)).roundToDouble(),
              ),
            ),
            Text('$progress%')
          ],
        ),
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [Text(startDate), Text(finishDate)],
        ),
      ],
    )),
  ],
);
}

我的 output,在此處輸入圖像描述

但是當我更改屏幕的寬度時出現此錯誤,請在此處輸入圖像描述

我想要的是 LinearProgressIndicator 根據屏幕寬度做出響應。請幫助!!!

Expanded包裹LinearProgressIndicator

            Expanded(
              child: LinearProgressIndicator(
                value: int.parse(progress) * 0.01,
                valueColor: AlwaysStoppedAnimation<Color>(LightSeaGreen),
                backgroundColor: Colors.greenAccent,

                // (int.parse(progress)).roundToDouble(),
              ),
            ),

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM