交互提示方式dialog和snackbar

首先看看dialog的方式

 new PopupMenuButton(
                    icon: new Icon(Icons.phone_iphone, color: Colors.blue,),
                   onSelected: (v){
                     showDialog<Null>(
                       context: context,
                       builder:(_){
                         return new AlertDialog(
                                    content: new Text(v),
                                    actions: <Widget>[
                                      new FlatButton(
                                        onPressed: () {
                                          Navigator.of(_).pop();
                                        },
                                        child: new Text('确定')
                                      )
                                    ]
                                  );
                                  }
                                );
                            },
                  
                    itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
                      new PopupMenuItem<String>(
                          value: '选项一的值',
                          child: new Text('屏蔽这个问题')
                      ),
                      new PopupMenuItem<String>(
                          value: '选项二的值',
                          child: new Text('取消关注')
                      ),
                      new PopupMenuItem<String>(
                          value: '选项二的值',
                          child: new Text("举报")
                      )
                    ]
                  
                  ),
       

snackbar

 new PopupMenuButton(
                    icon: new Icon(Icons.phone_iphone, color: Colors.blue,),
                   //child: ImageIcon(AssetImage('images/wxzf.png'), size:20.0, color: Colors.blue,),
                   onSelected: (v){
        final snackBar = new SnackBar(
          content: new ListTile(leading: Icon(Icons.warning,color: Colors.red,),title: new Text(v),),
          backgroundColor: Colors.blue,
          duration: Duration(milliseconds: 2000),
          );

Scaffold.of(context).showSnackBar(snackBar);             
 },
                  
                    itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
                      new PopupMenuItem<String>(
                          value: '选项一的值',
                          child: new Text('屏蔽这个问题')
                      ),
                      new PopupMenuItem<String>(
                          value: '选项二的值',
                          child: new Text('取消关')
                      ),
                      new PopupMenuItem<String>(
                          value: '选项二的值',
                          child: new Text("举报")
                      )
                    ]
                  
                  ),
      

 

相关文章:

  • 2022-12-23
  • 2021-10-10
  • 2021-08-23
  • 2022-12-23
  • 2022-01-24
  • 2022-12-23
  • 2021-09-19
  • 2022-01-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
  • 2021-12-16
  • 2021-10-09
  • 2021-12-07
  • 2022-12-23
相关资源
相似解决方案