- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我开发了一个 Flutter 应用程序,我使用了 ProgressDialog
小部件 ( progress_dialog: ^1.2.0
)。首先,我展示了 ProgressDialog
小部件和一些代码之后,然后我尝试隐藏 ProgressDialog。但它不起作用。
这是我的代码
class SignUp extends StatefulWidget {
@override
_SignUpState createState() => _SignUpState();
}
class _SignUpState extends State<SignUp> {
@override
Widget build(BuildContext context) {
pr = new ProgressDialog(context,type: ProgressDialogType.Normal);
pr.style(
message: 'Sing Up .......',
borderRadius: 20.0,
backgroundColor: Colors.white,
progressWidget: CircularProgressIndicator(),
maxProgress: 1.0,
);
return Scaffold(
backgroundColor: Color.fromRGBO(23, 63, 73, 1),
appBar: AppBar(
title: Text("Sign up"),
backgroundColor: Colors.black,
),body: Stack(
......
_addUser();
),
);
}
Future _addUser() async {
pr.show();
.........
pr.hide();
}
}
Future.delayed(Duration(seconds: 3)).then((value) {
pr.hide();
});
ProgressDialog.hide()
在这里不起作用,但它在延迟过程后起作用了??
最佳答案
当您的代码执行到 pr.hide() 时,progress_dialog 仍然没有显示在屏幕上
所以你的 pr.hide() 不起作用
你可以看到问题 https://github.com/fayaz07/progress_dialog/issues/38
并检查 pr.isShowing() 将不起作用,因为在 progress_dialog https://github.com/fayaz07/progress_dialog/blob/master/lib/progress_dialog.dart 的源代码中
bool _isShowing
领先于真实showDialog()
progress_dialog 的代码片段
void show() {
if (!_isShowing) {
_dialog = new _Body();
_isShowing = true;
if (_showLogs) debugPrint('ProgressDialog shown');
showDialog<dynamic>(
context: _context,
barrierDismissible: false,
builder: (BuildContext context) {
_dismissingContext = context;
return WillPopScope(
onWillPop: () {
return Future.value(_barrierDismissible);
},
child: Dialog(
backgroundColor: _backgroundColor,
insetAnimationCurve: _insetAnimCurve,
insetAnimationDuration: Duration(milliseconds: 100),
elevation: _dialogElevation,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.all(Radius.circular(_borderRadius))),
child: _dialog),
);
},
);
} else {
if (_showLogs) debugPrint("ProgressDialog already shown/showing");
}
}
}
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:progress_dialog/progress_dialog.dart';
ProgressDialog pr;
void main() {
runApp(MaterialApp(
home: FirstScreen(),
));
}
class MyApp extends StatelessWidget {
double percentage = 0.0;
@override
Widget build(BuildContext context) {
// pr = new ProgressDialog(context,
// type: ProgressDialogType.Normal, isDismissible: false);
pr = new ProgressDialog(context, type: ProgressDialogType.Download);
pr.style(
message: 'Downloading file...',
borderRadius: 10.0,
backgroundColor: Colors.white,
elevation: 10.0,
insetAnimCurve: Curves.easeInOut,
progress: 0.0,
maxProgress: 100.0,
progressTextStyle: TextStyle(
color: Colors.black, fontSize: 13.0, fontWeight: FontWeight.w400),
messageTextStyle: TextStyle(
color: Colors.black, fontSize: 19.0, fontWeight: FontWeight.w600),
);
return Scaffold(
body: Center(
child: RaisedButton(
child: Text(
'Show Dialog',
style: TextStyle(color: Colors.white),
),
color: Colors.blue,
onPressed: () {
pr.show();
Future.delayed(Duration(seconds: 2)).then((onvalue) {
percentage = percentage + 30.0;
print(percentage);
pr.update(
progress: percentage,
message: "Please wait...",
progressWidget: Container(
padding: EdgeInsets.all(8.0),
child: CircularProgressIndicator()),
maxProgress: 100.0,
progressTextStyle: TextStyle(
color: Colors.black,
fontSize: 13.0,
fontWeight: FontWeight.w400),
messageTextStyle: TextStyle(
color: Colors.black,
fontSize: 19.0,
fontWeight: FontWeight.w600),
);
Future.delayed(Duration(seconds: 2)).then((value) {
percentage = percentage + 30.0;
pr.update(
progress: percentage, message: "Few more seconds...");
print(percentage);
Future.delayed(Duration(seconds: 2)).then((value) {
percentage = percentage + 30.0;
pr.update(progress: percentage, message: "Almost done...");
print(percentage);
Future.delayed(Duration(seconds: 2)).then((value) {
pr.hide().whenComplete(() {
print(pr.isShowing());
});
percentage = 0.0;
});
});
});
});
Future.delayed(Duration(seconds: 10)).then((onValue) {
print("PR status ${pr.isShowing()}");
if (pr.isShowing())
pr.hide().then((isHidden) {
print(isHidden);
});
print("PR status ${pr.isShowing()}");
});
}),
),
);
}
}
class FirstScreen extends StatefulWidget {
@override
_FirstScreenState createState() => _FirstScreenState();
}
class _FirstScreenState extends State<FirstScreen> {
ProgressDialog pr;
@override
Widget build(BuildContext context) {
pr = new ProgressDialog(context, showLogs: true);
pr.style(message: 'Please wait...');
return Scaffold(
body: Center(
child: RaisedButton(
child: Text('Show dialog and go to next screen',
style: TextStyle(color: Colors.white)),
color: Colors.blueAccent,
onPressed: () async{
print("before pr show");
pr.show();
print("after pr show");
print(pr.isShowing());
pr.hide().whenComplete((){print("hide complete");}
);
print("after pr hide");
print(pr.isShowing());
/*Future.delayed(Duration(seconds: 3)).then((value) {
pr.hide().whenComplete(() {
Navigator.of(context).push(CupertinoPageRoute(
builder: (BuildContext context) => SecondScreen()));
});
});*/
},
),
),
);
}
}
class SecondScreen extends StatefulWidget {
@override
_SecondScreenState createState() => _SecondScreenState();
}
class _SecondScreenState extends State<SecondScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(child: Text('I am second screen')),
);
}
}
关于Flutter ProgressDialog 隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59448216/
当用户点击登录按钮时,我想在我的应用程序中使用 ProgressDialog。我遇到的问题是未找到 ProgressDialog - AS 中的红色文本。我错过了什么图书馆吗? 渐变 compile
我使用进度条创建了自定义进度对话框,但自定义进度对话框中的进度消息没有更新 最佳答案 您可以使用 ProgressBar实现相同的行为进度对话框 CustomProgressBar progressB
给出下面的代码。我想将标题“请等待调用被激活”转换为印地语(我在 Assets 文件夹中提供的字体).. public ShakeEventsListener(Context context, OnS
当我的设备是 4.4.4 时,我的 ProgressDialog 工作正常,我最近没有使用这个应用程序,同时设备升级到 Lillipop。我不确定这是否对这个问题造成了任何影响,只是提一下。 问题 1
ProgressDialog 在我的代码中添加 progressDialog.dismiss() 方法时无法显示 我还尝试添加Thread.sleep(),以便它的执行将 hibernate 一段时间
我只是想创建一个旋转的进度对话框。没有文字,没有边框,没有背景。只是一个旋转的通知,轻轻地位于内容顶部的屏幕中心。 我在创建这个自定义对话框时看到了两个不同的 Stack Overflow 问题。 他
我的意思是,ProgressDialog 静态方法 show() 的返回值与该类实例的非静态方法 show 之间有什么区别? 有什么理由选择这种策略 ProgressDialog pd = new P
我在进程运行时使用 ProgressDialog 时遇到问题。我已经尝试了所有可能的不正确方法,并查看了许多网站,这些网站提供了我正在尝试做的事情的示例,但是,我仍然遇到了线程在 ProgressDi
我开发了一个 Flutter 应用程序,我使用了 ProgressDialog小部件 ( progress_dialog: ^1.2.0 )。首先,我展示了 ProgressDialog小部件和一些代
在应用程序中创建ProgressDialog时,出现BadTokenException错误。我尝试阅读有关该问题的几篇文章,但我仍然无法真正弄清这是什么原因。单击按钮后,我调用对话框函数。 p
以下是我的代码: public void onClick(View view) { dialog=new ProgressDialog(view.getContext());
我有一个进度对话框,可以工作,但不符合我的外部需求: 我想把它做成这样: 我尝试过的: 1 - 主题化(仅使用样式和样式+主题方法),如此处所述 结果很糟糕(我在对话框周围有一个相同的蓝色边框颜色和标
我正在尝试从互联网获取数据,解析它,然后将数据显示给用户。该操作通常需要 3 秒左右,我希望旋转进度对话框显示一条消息,说明我正在加载数据。问题是 ProgressDialog 仅在加载即将完成时才显
我制作了一个食谱应用程序,我一直在解决一些问题,因为我无法运行该应用程序,但似乎每次修复错误时都会出现另一个错误,我的项目无法解决方法解雇()我不知道该怎么办,我已经根据 Youtube channe
我想从外部类中显示当前 Activity 的 ProgressDialog,而不是将变量传递到外部类或像其他已回答的问题一样使用静态变量。是否可以?这是一些简单的测试代码,可能有助于说明我想要做什么:
在“onCreate”中,我正在从网络下载数据。下载数据的持续时间为 10 秒。我不想在下载数据时使用 ProgressDialog。这是我的代码,但 ProgressDialog 没有出现: pub
我的应用程序正在从网络服务器加载一些数据。这次我想要一个进度对话框以避免应用程序用户出现黑屏。 Button ok = (Button) findViewById(R.id.ok);
我在我的 android 应用程序中创建了一个 ProgressDialog。但我遇到的问题是在它实际完成工作时停止旋转轮子。这是我的代码。我怎样才能让它在我进行其他工作时不断旋转轮子? button
我能做到: ((Activity) mContext).setProgressBarIndeterminateVisibility(true); 但不是这个: ((Activity) mConte
我想从服务内的线程增加一个进度对话框,我真的很难做到,这是我的代码,请帮助我。 我尝试了很多不同的方法,包括 asyncTask(我遇到了上下文问题)并尝试使用静态函数但它无法正常工作,我是 andr
我是一名优秀的程序员,十分优秀!