0

我是颤振世界的新手,我想知道如何从颤动的圆形进度指示器中删除这个白色背景。下面我将留下截图和我的代码。

屏幕

代码:

import 'package:flutter/material.dart';

void showLoading(BuildContext context, {required String text}) {
  showDialog(
    context: context,
    barrierDismissible: false,
    builder: (_) {
      return SimpleDialog(
        children: <Widget>[
          Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              CircularProgressIndicator(
                color: Theme.of(context).primaryColor,
              ),
              const SizedBox(height: 10),
              Text(text, textAlign: TextAlign.center),
            ],
          ),
        ],
      );
    },
  );
}

void hideLoading(BuildContext context) {
  if (Navigator.canPop(context)) {
    Navigator.of(context).pop();
  }
}
4

2 回答 2

0

我希望这个答案对您有所帮助,您需要更改下的背景颜色SimpleDialog

void showLoading(BuildContext context, String text) {
showDialog(
  context: context,
  barrierDismissible: false,
  builder: (_) {
    return SimpleDialog(
      backgroundColor: Colors.transparent,//here set the color to transparent
      elevation: 0,
      children: <Widget>[
        Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            CircularProgressIndicator(
              color: Theme.of(context).primaryColor,
            ),
            const SizedBox(height: 10),
            Text(text, textAlign: TextAlign.center),
          ],
        ),
      ],
    );
  },
);
 }
于 2022-01-22T03:29:41.373 回答
0

用这个

             showDialog(
                context: context,
                barrierDismissible: false,
                builder: (_) {
                  return Center(
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        CircularProgressIndicator(
                          color: Theme.of(context).primaryColor,
                        ),
                        const SizedBox(height: 10),
                        Text(text, textAlign: TextAlign.center),
                      ],
                    ),
                  );
                },
              );
于 2022-01-22T03:33:24.113 回答