startProgress static method
Implementation
static void startProgress({@required int maxSecond, @required Widget child}) {
StreamProvider _streamProvider = StreamProvider();
_streamProvider.isLoading = true;
int count = 0;
showDialog(
barrierDismissible: false,
context: _globalProvider.globalContext,
builder: (context) {
Timer.periodic(const Duration(milliseconds: 250), (Timer t) {
count++;
if (!_streamProvider.isLoading) {
t.cancel();
// Navigator.pop(_globalProvider.globalContext);
Navigator.of(_globalProvider.globalContext, rootNavigator: true)
.pop();
} else if (count >= maxSecond * 4) {
t.cancel();
// Navigator.pop(_globalProvider.globalContext);
Navigator.of(_globalProvider.globalContext, rootNavigator: true)
.pop();
}
});
return WillPopScope(
onWillPop: () {
return Future.value(false);
},
child: AlertDialog(
elevation: 0,
backgroundColor: Colors.transparent,
content: child,
),
);
},
);
}