diff --git a/packages/smooth_app/lib/generic_lib/loading_dialog.dart b/packages/smooth_app/lib/generic_lib/loading_dialog.dart index 60563c5505c..19a7132ca6d 100644 --- a/packages/smooth_app/lib/generic_lib/loading_dialog.dart +++ b/packages/smooth_app/lib/generic_lib/loading_dialog.dart @@ -93,19 +93,22 @@ class LoadingDialog { body: FutureBuilder( future: future, builder: (BuildContext context, AsyncSnapshot snapshot) { - if (snapshot.hasData) { + if (snapshot.connectionState == ConnectionState.done) { + // Now it's either hasError or successful. + // We cannot check hasData because data can be null or void. + if (snapshot.hasError) { + return ListTile( + title: Text(appLocalizations!.error_occurred), + ); + } _popDialog(context, snapshot.data); + // whatever, anyway we've just pop'ed return Container(); - } else if (snapshot.hasError) { - return ListTile( - title: Text(appLocalizations!.error_occurred), - ); - } else { - return ListTile( - leading: const CircularProgressIndicator(), - title: Text(title), - ); } + return ListTile( + leading: const CircularProgressIndicator(), + title: Text(title), + ); }, ), actions: [