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

Flutter中CircularProgressIndicator在Android端显示异常求助

Fixing Android's CircularProgressIndicator Showing Only a Dot (Works on iOS)

Hey Marco, I’ve run into this exact Android-specific quirk with Flutter’s CircularProgressIndicator before—let’s walk through the most common fixes:

1. Explicitly Set strokeWidth

The default strokeWidth (2.0) can sometimes render as a tiny dot on Android due to theme or device density differences. Override it with a clearer value to ensure the indicator has enough visual weight:

Center(child: CircularProgressIndicator(
  strokeWidth: 4.0, // Adjust this to your preferred thickness
));

2. Check Your App’s Progress Indicator Theme

If you’re using a custom ThemeData, it might be overriding the stroke width globally for Android. You can either update the global theme or wrap the indicator in a local Theme to override the setting:

Global Theme Fix:

MaterialApp(
  theme: ThemeData(
    progressIndicatorTheme: ProgressIndicatorThemeData(
      strokeWidth: 4.0, // Set a consistent width across all platforms
    ),
  ),
  // ... rest of your app configuration
);

Local Override:

Center(
  child: Theme(
    data: Theme.of(context).copyWith(
      progressIndicatorTheme: ProgressIndicatorThemeData(strokeWidth: 4.0),
    ),
    child: CircularProgressIndicator(),
  ),
);

3. Ensure Proper Container Constraints

Sometimes the CircularProgressIndicator gets squeezed by a parent container with tight constraints. Wrap it in a SizedBox to guarantee enough space for the full indicator to render:

Center(
  child: SizedBox(
    width: 40,
    height: 40,
    child: CircularProgressIndicator(),
  ),
);

Quick Syntax Fix for Your Sample Code

I spotted a tiny syntax error in your error handler that could cause runtime issues: Text('Error') is missing a closing parenthesis. Here’s the corrected line:

if (snapshot.hasError) return Center(child: Text('Error'));

Start with the strokeWidth fix first—it’s the most likely culprit for this platform-specific discrepancy. Let me know if any of these solve your issue!

内容的提问来源于stack exchange,提问作者Marco Mascii

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.07 13:22:29