flutter - 使 CircularProgressIndicator 的背景在颤动中透明
问题描述
我在登录时在我的应用程序中集成了 CircularProgressIndicator。该指示器根据需要可见,但它用白色覆盖层隐藏了我的登录屏幕。我想让它的背景透明而不是白色。我试图给 CircularProgressIndicator 的背景颜色,但它没有做任何改变。这是我的代码:
child: !_isLoading ? _loginScreen(loginBloc.state) : Center(
child: const SizedBox(
width: 40,
height: 40,
child: CircularProgressIndicator(),
),
)
谢谢你。
解决方案
您可以Stack
在其子项上使用不同的不透明度。
例如
Stack(
children: <Widget>[
Opacity(
opacity: 1, // You can reduce this when loading to give different effect
child: AbsorbPointer(
absorbing: _isLoading,
child: _loginScreen(loginBloc.state),
),
),
Opacity(
opacity: _isLoading ? 1.0 : 0,
child: CircularProgressIndicator(),
),
],
);
如果您想要有效的解决方案,我会在https://github.com/yagnyam-in/proxy-flutter/blob/master/lib/widgets/loading.dart、https://github.com/yagnyam-中大量使用它在/proxy-flutter/blob/master/lib/widgets/async_helper.dart
推荐阅读
- c - 嗨,我正在为此硬件编码,使用信号(sigaction,sigprocmask)
- python - 使用 ffmpeg 将 youtube 音频转换为 .mp3:错误:音频转换失败:编码器:Lavc58.91.100 libmp3lame
- arrays - 需要帮助在 perl 中填充结构数组
- amazon-web-services - Terraform 总是说 s3 存储桶策略的模板文件更改
- flutter - 你能改变颤动的文字主题吗?
- javascript - 单击特定按钮时,如何使 div 缓慢滑出(使用 CSS 的转换属性)?
- visualforce - Visualforce 页面上的美国国家选项列表
- python-3.x - KivyMD onkeypress 事件 - Python
- php - 为什么重定向不起作用?你会如何解决它?
- firebase - Firebase 存储规则奇怪的行为