【问题标题】:flutter alertdialog with background image带有背景图像的颤动警报对话框
【发布时间】:2021-11-08 00:37:51
【问题描述】:

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

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) {
                                },
                              ),
                            )),
                          ],
                        ),
                      ],
                    ),
                  ),
                );

【问题讨论】:

    标签: flutter background-image flutter-alertdialog


    【解决方案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,
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                ), 
    

    您的结果屏幕->

    【讨论】:

      猜你喜欢
      • 2013-03-09
      • 2015-06-07
      • 2019-10-27
      • 2018-11-30
      • 2013-01-07
      • 1970-01-01
      • 2019-08-08
      • 2019-11-15
      • 2017-05-10
      相关资源
      最近更新 更多