showLoader function

Future<void> showLoader({
  1. bool isModal = false,
  2. Color? modalColor,
  3. bool modalDismissible = true,
})

To handle a loader for the application

Implementation

Future<void> showLoader(
    {bool isModal = false,
    Color? modalColor,
    bool modalDismissible = true}) async {
  try {
    _printLog('''Showing loader as Overlay''');
    final _child = Center(
      child: _loadingIndicator ??
          (Platform.isAndroid
              ? CircularProgressIndicator()
              : CupertinoActivityIndicator()),
    );
    await _showOverlay(
      child: isModal
          ? Stack(
              children: <Widget>[
                ModalBarrier(
                  color: modalColor ?? _modalBarrierDefaultColor,
                  dismissible: modalDismissible,
                ),
                _child
              ],
            )
          : _child,
      type: _OverlayType.Loader,
    );
  } catch (err) {
    debugPrint(
        '''Caught an exception while trying to show a Loader\n${err.toString()}''');
    throw err;
  }
}