flutter 交互提示方式


交互提示方式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("舉報")
                      )
                    ]
                  
                  ),
      

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM