show static method
void
show(})
If you need to show an normal overlayloader,
just call Loader.show(context)
with a build context.
BuildContext is a required param.
Implementation
static void show(
BuildContext context, {
/// Define your custom progress indicator if you want [optional]
Widget? progressIndicator,
/// Define Theme [optional]
ThemeData? themeData,
/// Define Overlay color [optional]
Color? overlayColor,
/// overlayTop mean overlay start from Top margin.
///
/// If you have custom appbar and you want to show loader without custom
/// appbar then will be custom appbar height here and also you have to make
/// sure [isAppbarOverlay = false].
double? overlayFromTop,
/// overlayFromBottom mean overlay end to Bottom margin.
///
/// If you have custom BottomAppBar and you want to show loader without
/// custom BottomAppBar then will be custom BottomAppBar height here and
/// also you have to make sure [isBottomBarOverlay = false].
double? overlayFromBottom,
/// isAppbarOverlay default true.
///
/// If you need to appbar outside from overlay loader then make it false.
bool isAppbarOverlay = true,
/// isBottomBarOverlay default true.
///
/// If you need to BottomBar outside from overlay loader then make it false.
bool isBottomBarOverlay = true,
/// isSafeAreaOverlay default true.
///
/// If you don't want to overlay your safe area like statusBar and
/// bottomNavBar then make it false.
bool isSafeAreaOverlay = true,
}) {
var safeBottomPadding = MediaQuery.of(context).padding.bottom;
var defaultPaddingTop = 0.0;
var defaultPaddingBottom = 0.0;
if (!isAppbarOverlay) {
isSafeAreaOverlay = false;
}
if (!isSafeAreaOverlay) {
defaultPaddingTop = defaultValue;
defaultPaddingBottom = defaultValue + safeBottomPadding;
} else {
defaultPaddingTop = defaultValue;
defaultPaddingBottom = defaultValue;
}
_overlayState = Overlay.of(context);
if (_currentLoader == null) {
///Create current Loader Entry
_currentLoader = OverlayEntry(builder: (context) {
return Stack(
children: <Widget>[
_overlayWidget(
isSafeAreaOverlay,
overlayColor ?? Color(0x99ffffff),
isAppbarOverlay ? 0.0 : overlayFromTop ?? defaultPaddingTop,
isBottomBarOverlay
? 0.0
: overlayFromBottom ?? defaultPaddingBottom),
Center(
child: Loader._(
progressIndicator,
themeData,
)),
],
);
});
try {
widgetBind?.addPostFrameCallback((_) {
if (_currentLoader != null) {
_overlayState?.insert(_currentLoader!);
}
});
} catch (e) {
print(e.toString());
}
}
}