appbar不太好用,定制的太强,不灵活
因为appbar是实现了PreferredSizeWidget,所以我们只要实现这个接口就可以了
import 'package:flutter/material.dart';
import 'package:flutter_app/utils/windowUtil.dart';
class AppBarTemp extends StatefulWidget implements PreferredSizeWidget
{
String title;
Color color;
AppBarTemp(this.title,{this.color});
@override
State<AppBarTemp> createState() => _AppBarTempState();
@override
Size get preferredSize {
return new Size.fromHeight(56.0);
}
}
class _AppBarTempState extends State<AppBarTemp> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return
new Container(
color: widget.color,
width: windowUtil.width,
child:
Container(
margin: EdgeInsets.only(top: windowUtil.statusbar,left: 20.0),
alignment: Alignment.centerLeft,
child: Text(widget.title,style: TextStyle(color: Color(0xffffffff),fontSize: 20.0),),
),
);
}
}
现在可以随便搞
效果