Search code examples
flutterdartflutter-layoutloaderflutter-animation

how to get custom circular progress indicator as shown in image with flutter?


I tried to get this circular progress indicator in alert dialog type. here's my code and output below.

code:

Future<void> loaderDialogNormal(BuildContext context) { 
    return showDialog<void>(
            context: context,
            builder: (BuildContext context) {
                 return  Dialog(
            shape: RoundedRectangleBorder(
                borderRadius:
                    BorderRadius.circular(20.0)),
            child: 
                 Container(
                   width: 50, height: 50,
                   child: CircularProgressIndicator()),
            );
            });
  }

my output:

my output for code

expected output:

expected output

how to achieve the expected output?


Solution

  • Try this code, It works as you want

    Future<void> loaderDialogNormal(BuildContext context) {
        showDialog(
            context: context,
            barrierDismissible: false,
            builder: (_) {
              return Center(
                  child: Container(
                    width: 100.0,
                    height: 100.0,
                    decoration: ShapeDecoration(
                      color: Colors.white,
                      shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.all(
                          Radius.circular(10.0),
                        ),
                      ),
                    ),
                    child: Center(
                      child: CircularProgressIndicator(
                        valueColor: AlwaysStoppedAnimation<Color>(
                            Colors.grey),
                      ),
                    ),
                  ));
            });
      }