Flutter 顶部 选项卡 分享 更多按钮 和返回

renyonggang 25 0

import 'package:flutter/material.dart';

 

void main() => runApp(new MyApp());

 

class MyApp extends StatelessWidget {

  @override

  Widget build(BuildContext context) {

    return new MaterialApp(

      title: '测试scallfod',

      home: Scaffold(

        appBar: AppBar(

          centerTitle: true,

          leading: IconButton(

            icon: Icon(Icons.surround_sound),

            onPressed: () {

              Navigator.pop(context);

            },

          ),

          title: Text('scallfold 测试'),

          actions: <Widget>[

            IconButton(

              icon: Icon(Icons.share),

              onPressed: () {

                print('点击');

              },

            ),

            PopupMenuButton(

              itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[

                PopupMenuItem<String>(

                  child: Text("热度"),

                  value: "hot",

                ),

                PopupMenuItem<String>(

                  child: Text("最新"),

                  value: "new",

                ),

              ],

              onSelected: (String action) {

                switch (action) {

                  case "hot":

                    print("hot");

                    break;

                  case "new":

                    print("new");

                    break;

                }

              },

              onCanceled: () {

                print("onCanceled");

              },

            )

          ],

        ),

        body: Container(

          color: Colors.indigo,

        ),

      ),

    );

  }

}

 

打赏 支付宝打赏 微信打赏

发表评论 (已有0条评论)

还木有评论哦,快来抢沙发吧~

请先 登录 再评论,若不是会员请先 注册