diff --git a/lib/modal_progress_hud.dart b/lib/modal_progress_hud.dart index da9186d..fd031b1 100644 --- a/lib/modal_progress_hud.dart +++ b/lib/modal_progress_hud.dart @@ -48,26 +48,27 @@ class ModalProgressHUD extends StatelessWidget { Widget build(BuildContext context) { if (!inAsyncCall) return child; - Widget layOutProgressIndicator; - if (offset == null) - layOutProgressIndicator = Center(child: progressIndicator); - else { - layOutProgressIndicator = Positioned( - child: progressIndicator, - left: offset.dx, - top: offset.dy, - ); - } - - return new Stack( + return Stack( children: [ child, - new Opacity( - child: new ModalBarrier(dismissible: dismissible, color: color), + Opacity( + child: ModalBarrier(dismissible: dismissible, color: color), opacity: opacity, ), - layOutProgressIndicator, + _getLayOutProgressIndicator(), ], ); } + + Widget _getLayOutProgressIndicator() { + if (offset == null) { + return Center(child: progressIndicator); + } + + return Positioned( + child: progressIndicator, + left: offset.dx, + top: offset.dy, + ); + } }