Skip to content

Instantly share code, notes, and snippets.

@AyeshaIftikhar
Last active September 12, 2021 15:52
Show Gist options
  • Save AyeshaIftikhar/cd6465b7f8e0e9615a189a8292576a6c to your computer and use it in GitHub Desktop.
Save AyeshaIftikhar/cd6465b7f8e0e9615a189a8292576a6c to your computer and use it in GitHub Desktop.
Loading Dialog in Flutter

Loading Dialog

To show the user that application is working or not stuff at a particular functionality.

loadingDialog(BuildContext context, {required String text}) {
  return showDialog(
    context: context,
    barrierDismissible: false,
    builder: (context) {
      return SizedBox(
        width: 400,
        child: AlertDialog(
          elevation: 5.0,
          scrollable: true,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(15),
          ),
          title: SizedBox(
            width: 400,
            child: Row(
              mainAxisSize: MainAxisSize.min,
              children: [
                CircularProgressIndicator(
                  backgroundColor: Colors.black,
                  valueColor: AlwaysStoppedAnimation(Colors.red),
                ),
                horizontalSpacer(width: 10),
                Text(text),
              ],
            ),
          ),
        ),
      );
    },
  );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment