This repository has been archived by the owner on Nov 24, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 134
.update not working #22
Labels
waiting for response
waiting for the customer to respond with the updated code/comment
Comments
try writing this line inside the build() method _progressDialog = ProgressDialog(context, isDismissible: false); |
fayaz07
added
the
waiting for response
waiting for the customer to respond with the updated code/comment
label
Sep 20, 2019
@fayaz07 i've put this code inside build method _progressDialog = ProgressDialog(context, isDismissible: false); Error still same |
Can you post sample code, where you have encountered this issue? |
Here sample code import 'dart:async';
import 'package:flutter/material.dart';
import 'package:progress_dialog/progress_dialog.dart';
class TestScreen extends StatefulWidget {
TestScreen({Key key}) : super(key: key);
_TestScreenState createState() => _TestScreenState();
}
class _TestScreenState extends State<TestScreen> {
ProgressDialog _progressDialog;
int a = 0;
void _showLoading() {
try {
_progressDialog = ProgressDialog(context, isDismissible: true);
_progressDialog.show();
// change variable
setState(() {
a=1;
});
_progressDialog.update(
message: 'Uploading profile picture',
);
// change variable
setState(() {
a=2;
});
Timer(
Duration(seconds: 3),
() {
print('must hide now');
_progressDialog.hide();
},
);
} catch (err) {
print('err $err');
_progressDialog.hide();
}
}
@override
Widget build(BuildContext context) {
return Container(
child: RaisedButton(
onPressed: _showLoading,
child: Text(
'Show loading',
),
),
);
}
}
the problem maybe we can't setState if progress dialog is updating |
there is a check, if the progress dialog is showing, only then setState will be called |
so what is the solution? |
I haven't checked your code, I will update to you after checking. Thank You |
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:progress_dialog/progress_dialog.dart';
void main(){
runApp(MaterialApp(home: TestScreen()));
}
class TestScreen extends StatefulWidget {
TestScreen({Key key}) : super(key: key);
_TestScreenState createState() => _TestScreenState();
}
class _TestScreenState extends State<TestScreen> {
ProgressDialog _progressDialog;
int a = 0;
void _showLoading() async{
try {
_progressDialog.show();
await Future.delayed(Duration(seconds: 2));
// change variable
setState(() {
a=1;
});
_progressDialog.update(
message: 'Uploading profile picture',
);
// change variable
setState(() {
a=2;
});
// Timer(
// Duration(seconds: 3),
// () {
// print('must hide now');
// _progressDialog.hide();
// },
// );
Future.delayed(Duration(seconds: 3)).whenComplete((){
_progressDialog.hide().then((value){
print("Hidden: $value");
});
});
} catch (err) {
print('err $err');
//_progressDialog.hide();
}
}
@override
Widget build(BuildContext context) {
_progressDialog = ProgressDialog(context, isDismissible: true);
return Scaffold(
body: Center(
child: RaisedButton(
onPressed: _showLoading,
child: Text(
'Show loading',
),
),
),
);
}
} Check this code, this is working perfectly |
I am closing this issue, you must read the logs and configure properly |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Lib version :
progress_dialog: ^1.2.0
Sample code:
Output:
Code is working if i comment
_progressDialog.update()
functionThe text was updated successfully, but these errors were encountered: