微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

flutter 学习笔记之封装一个appbar

# Flutter_appbar

封装一个简单的appbar,显示title和返回按钮和下面的分割线

- PreferredSizeWidget bottom 支持自定义bottom
- titleStyle 支持自定义title的风格
- backImgName 自定义返回按钮的图片
- backgroundColor 自定义导航栏颜色
 

核心代码

 Widget build(BuildContext context) {
    return AppBar(
      title: new Text(
        widget.title ?? 'title',
        style: new TextStyle(
          color: Colors.black,
          fontSize: 17.0,
          fontWeight: FontWeight.bold,
        ),
      ),
      leading: widget.isShowBack ?
      FlatButton(
        child: Image(
          image: new Assetimage('resources/[email protected]'),
          width: 9,
          height: 15,
        ),
        onpressed: () {
          Navigator.maybePop(context);
        },
      ) : null,
      backgroundColor: widget.backgroundColr ?? Colors.white,
      elevation: 0,
   
      bottom: new AppBarBottom(
        child: widget.bottom,
      ),
      actions: widget.actions,
    );
  }

源码:https://github.com/AnleSu/flutter_appbar

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐