[英]Circular progress indicator without white background
I'm new to the flutter world and I would like to know how to remove this white background from the circular progress indicator of flutter.我是 flutter 世界的新手,我想知道如何从 flutter 的圆形进度指示器中删除这个白色背景。 Below I will leave a screenshot and my code.
下面我将留下截图和我的代码。
Code:代码:
import 'package:flutter/material.dart';
void showLoading(BuildContext context, {required String text}) {
showDialog(
context: context,
barrierDismissible: false,
builder: (_) {
return SimpleDialog(
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
CircularProgressIndicator(
color: Theme.of(context).primaryColor,
),
const SizedBox(height: 10),
Text(text, textAlign: TextAlign.center),
],
),
],
);
},
);
}
void hideLoading(BuildContext context) {
if (Navigator.canPop(context)) {
Navigator.of(context).pop();
}
}
I hope this answer helps you, you need to change the background color under SimpleDialog我希望这个答案对你有帮助,你需要在 SimpleDialog 下更改背景颜色
void showLoading(BuildContext context, String text) { showDialog( context: context, barrierDismissible: false, builder: (_) { return SimpleDialog( backgroundColor: Colors.transparent, elevation: 0, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ CircularProgressIndicator( color: Theme.of(context).primaryColor, ), const SizedBox(height: 10), Text(text, textAlign: TextAlign.center), ], ), ], ); }, ); void showLoading(BuildContext context,String text){showDialog(context:context,barrierDismissible:false,builder:(_){return SimpleDialog(backgroundColor:Colors.transparent,海拔:0,孩子:[列(mainAxisAlignment:MainAxisAlignment.center,孩子:[CircularProgressIndicator(颜色:Theme.of(context).primaryColor,),const SizedBox(高度:10),Text(文本,textAlign:TextAlign.center),],),],);},); }
}
use this用这个
showDialog(
context: context,
barrierDismissible: false,
builder: (_) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
CircularProgressIndicator(
color: Theme.of(context).primaryColor,
),
const SizedBox(height: 10),
Text(text, textAlign: TextAlign.center),
],
),
);
},
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.