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.
HMG_Patient_App_New/lib/widgets/loader/bottomsheet_loader.dart

46 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/services/navigation_service.dart';
class LoaderBottomSheet {
static final NavigationService _navService = GetIt.I<NavigationService>();
static bool _isVisible = false;
static void showLoader() {
if (_isVisible) return;
_isVisible = true;
showModalBottomSheet(
context: _navService.navigatorKey.currentContext!,
isDismissible: false,
enableDrag: false,
backgroundColor: Colors.transparent,
builder: (_) {
return Container(
height: MediaQuery.of(_navService.navigatorKey.currentContext!).size.height * 0.3,
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
child: Center(
child: Utils.getLoadingWidget(),
),
);
},
).whenComplete(() {
// reset state if dismissed by system
_isVisible = false;
});
}
static void hideLoader() {
if (_isVisible) {
Navigator.of(_navService.navigatorKey.currentContext!).pop();
_isVisible = false;
}
}
}