You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			47 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Dart
		
	
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, {bool barrierDismissible = true}) {
 | 
						|
    // Remove the PostFrameCallback to show dialog immediately
 | 
						|
    if (!_isLoadingVisible) {
 | 
						|
      _isLoadingVisible = true;
 | 
						|
      showDialog(
 | 
						|
        barrierDismissible: barrierDismissible,
 | 
						|
        context: context,
 | 
						|
        barrierColor: Colors.black.withOpacity(0.5),
 | 
						|
        useRootNavigator: false,
 | 
						|
        builder: (BuildContext context) => GifLoaderContainer(
 | 
						|
          barrierDismissible: barrierDismissible,
 | 
						|
        ),
 | 
						|
      ).then((value) {
 | 
						|
        _isLoadingVisible = false;
 | 
						|
      });
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
  static hideDialog(BuildContext context) {
 | 
						|
    try {
 | 
						|
 | 
						|
      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, rootNavigator: true).canPop());
 | 
						|
      // Future.delayed(Duration(milliseconds: 250)).then((value) => Navigator.of(context, rootNavigator: true).canPop());
 | 
						|
      if (_isLoadingVisible) {
 | 
						|
        _isLoadingVisible = false;
 | 
						|
        Navigator.of(context).pop();
 | 
						|
      }
 | 
						|
      _isLoadingVisible = false;
 | 
						|
    }
 | 
						|
  }
 | 
						|
} |