解决方法
在撰写本文时,我不知道PreferredSize. Cinn的答案更好地实现了这一目标.
import "package:Flutter/material.dart"; class Page extends StatelessWidget { @override Widget build(BuildContext context) { return new Column(children : <Widget>[new CustomAppBar("Custom App Bar"),new Container()],); } } class CustomAppBar extends StatelessWidget { final String title; final double barHeight = 50.0; // change this for different heights CustomAppBar(this.title); @override Widget build(BuildContext context) { final double statusbarHeight = MediaQuery .of(context) .padding .top; return new Container( padding: new EdgeInsets.only(top: statusbarHeight),height: statusbarHeight + barHeight,child: new Center( child: new Text( title,style: new TextStyle(fontSize: 20.0,fontWeight: FontWeight.bold),),); } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。