Unity_UIWidgets学习笔记06_组件AppBar

1,构造函数

public AppBar(
            Key key = null,
            Widget leading = null,//前面显示的
            bool automaticallyImplyLeading = true,
            Widget title = null,//内容
            List<Widget> actions = null,//一个 Widget 列表,代表 Toolbar 中所显示的菜单,对于常用的菜单,通常使用 IconButton 来表示;对于不常用的菜单通常使用 PopupMenuButton 来显示为三个点,点击后弹出二级菜单
            Widget flexibleSpace = null,//一个显示在 AppBar 下方的控件,高度和 AppBar 高度一样,可以实现一些特殊的效果,该属性通常在 SliverAppBar 中使用
            PreferredSizeWidget bottom = null,//一个 AppBarBottomWidget 对象,通常是 TabBar。用来在 Toolbar 标题下面显示一个 Tab 导航栏
            float? elevation = null,//设计中控件的 z 坐标顺序,默认值为 4,对于可滚动的 SliverAppBar,当 SliverAppBar 和内容同级的时候,该值为 0, 当内容滚动 SliverAppBar 变为 Toolbar 的时候,修改 elevation 的值
            Color backgroundColor = null,//背景颜色
            Brightness? brightness = null,//按钮主题 Brightness.dark黑色Brightness.light,亮光
            IconThemeData iconTheme = null,//App bar 上图标的颜色、透明度、和尺寸信息。
            TextTheme textTheme = null,//App bar 上的文字样式。
            bool primary = true,//此应用栏是否显示在屏幕顶部
            bool? centerTitle = null,//标题是否居中显示,默认值根据不同的操作系统,显示方式不一样,true居中 false居左
            float titleSpacing = NavigationToolbar.kMiddleSpacing,
            float toolbarOpacity = 1.0f,//应用栏工具栏的透明度
            float bottomOpacity = 1.0f//应用栏底部的透明度
        )

2、例子

new MaterialApp(
            home:new AppBar(
                title:new Text("标题"),
                centerTitle:true,
                leading:new Icon(Icons.arrow_back),
                backgroundColor:new Color(0xffDE331F),
               actions:new List<Widget>(){
                   new IconButton(
                       icon:new Icon(Icons.playlist_play),
                       tooltip:"Air it",
                       onPressed:()=>{}
                   ),
                   new IconButton(
                       icon:new  Icon(Icons.playlist_add),
                       tooltip: "Restitch it",
                       onPressed:()=>{}
                   ),
            new   IconButton(
                icon:new  Icon(Icons.playlist_add_check),
                tooltip: "Repair it",
                onPressed: ()=>{}
                )
               }
            )  
        );

猜你喜欢

转载自www.cnblogs.com/PandaHome/p/11113107.html
今日推荐