user9918
user9918

Reputation: 121

Flutter - change size of a CircularProgressIndicator in a dialog window

I would like to have a dialog window with a CircularProgressIndicator. I would like to specify a size for the dialog window, so I use a SizedBox. But if I change the values for high and width, only the high changes. The CircularProgressIndicator is an oval instead of a circle. How can I change the size?

This is my code

import 'package:flutter/material.dart';

class Dialogs{
waiting(BuildContext context){
  return showDialog(
    context: context,
    barrierDismissible: false,
    builder: (BuildContext context){
      return AlertDialog(
        content: SizedBox(
          width: 150.0,
          height: 150.0,
          child: CircularProgressIndicator(
        valueColor: AlwaysStoppedAnimation(Colors.blue),
        strokeWidth: 7.0)
        ),
        );
    }
  );
}
}

Upvotes: 7

Views: 4140

Answers (1)

Xander Terblanche
Xander Terblanche

Reputation: 384

Had the same problem a while ago. You can achieve the result you want by using this:

  AlertDialog(
      content: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          SizedBox(
            width: 150,
            height: 150,
            child: CircularProgressIndicator(),
          ),
        ],
      ),
    );

Upvotes: 11

Related Questions