0

以下是我的警报对话框代码,我需要为警报对话框设置背景图像而不是蓝色,需要显示设计

AlertDialog(
                  backgroundColor: Colors.blue,
                  titlePadding: EdgeInsets.all(0),
                  contentPadding: EdgeInsets.all(0),
                  title: Container(
                    decoration: BoxDecoration(
                        color: profile_edit_toolbar_color,
                        borderRadius: BorderRadius.all(Radius.circular(8))),
                    width: MediaQuery.of(context).size.width * 0.7,
                    height: MediaQuery.of(context).size.height * 0.5,
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.spaceAround,
                      children: [
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Padding(
                              padding: const EdgeInsets.all(18),
                              child: Text(
                                'Select countries to show',
                                style: TextStyle(
                                    color: Colors.yellow[300],
                                    fontSize: 20,
                                    fontFamily: fontFamily_3),
                                // style: CustomStyle.balooCustom(20, Colors.white)
                              ),
                            ),
                            IconButton(
                                onPressed: () {
                                  Navigator.of(context).pop();
                                },
                                icon: Icon(
                                  Icons.close,
                                  size: 25,
                                  color: Colors.white,
                                )),
                          ],
                        ),
                        Row(
                          children: [
                            Expanded(
                                child: Container(
                              height: 120,
                              child: DisplayCountriesForm(
                                countriesList: eventResponse.countriesList,
                                num: 0,
                                displayCountries: displayCountries,
                                onValueChanged: (updatedList) {
                                },
                              ),
                            )),
                            Expanded(
                                child: Container(
                              height: 120,
                              child: DisplayCountriesForm(
                                countriesList: eventResponse.countriesList,
                                num: 1,
                                displayCountries: displayCountries,
                                onValueChanged: (updatedList) {
                                },
                              ),
                            )),
                            Expanded(
                                child: Container(
                              height: 120,
                              child: DisplayCountriesForm(
                                countriesList: eventResponse.countriesList,
                                num: 2,
                                displayCountries: displayCountries,
                                onValueChanged: (updatedList) {
                                },
                              ),
                            )),
                          ],
                        ),
                      ],
                    ),
                  ),
                );
4

1 回答 1

1

试试下面的代码我已经添加了警报对话框的背景图片希望你的问题得到解决,也使用你的小部件并根据需要更改背景图片

     TextButton(
              child: Text('Pressed Me'),
              onPressed: () => showDialog(
                context: context,
                builder: (context) => AlertDialog(
                  content: Stack(
                    alignment: Alignment.center,
                    children: <Widget>[
                      Image.network(
                        'https://www.kindpng.com/picc/m/355-3557482_flutter-logo-png-transparent-png.png',
                      ),
                      Text(
                        'Add Your Text Here',
                        style: TextStyle(
                          fontSize: 24,
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            ), 

您的结果屏幕->在此处输入图像描述

于 2021-09-12T11:16:15.073 回答