|
|
|
|
@ -3,15 +3,40 @@ import 'package:flutter/material.dart';
|
|
|
|
|
import '../widgets/Loader/gif_loader_container.dart';
|
|
|
|
|
|
|
|
|
|
class GifLoaderDialogUtils {
|
|
|
|
|
static bool _isLoadingVisible = false;
|
|
|
|
|
|
|
|
|
|
static bool get isLoading => _isLoadingVisible;
|
|
|
|
|
|
|
|
|
|
static showMyDialog(BuildContext context) {
|
|
|
|
|
showDialog(context: context, builder: (cxt) => GifLoaderContainer());
|
|
|
|
|
// showDialog(context: context, builder: (cxt) => GifLoaderContainer());
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
_isLoadingVisible = true;
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
barrierColor: Colors.black.withOpacity(0.5),
|
|
|
|
|
useRootNavigator: false,
|
|
|
|
|
builder: (BuildContext context) => GifLoaderContainer(),
|
|
|
|
|
).then((value) {
|
|
|
|
|
_isLoadingVisible = false;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static hideDialog(BuildContext context) {
|
|
|
|
|
try {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
if (_isLoadingVisible) {
|
|
|
|
|
_isLoadingVisible = false;
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
}
|
|
|
|
|
_isLoadingVisible = false;
|
|
|
|
|
// Navigator.of(context, rootNavigator: true).canPop();
|
|
|
|
|
} catch (error) {
|
|
|
|
|
Future.delayed(Duration(milliseconds: 250)).then((value) => Navigator.of(context).canPop());
|
|
|
|
|
// Future.delayed(Duration(milliseconds: 250)).then((value) => Navigator.of(context, rootNavigator: true).canPop());
|
|
|
|
|
if (_isLoadingVisible) {
|
|
|
|
|
_isLoadingVisible = false;
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
}
|
|
|
|
|
_isLoadingVisible = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|