【发布时间】:2021-01-04 19:55:52
【问题描述】:
我的可重复使用应用栏无法解决两个问题。
- Appbar 的页面宽度不同。 Appbar shorter then page width
- 文本和图标似乎没有垂直居中。看起来 appbar 有一个边框! (如果我移动对齐,我可以播种边界。见图 2。 see white icon on the right
- 当我翻页时,似乎有一个 Appbar 在可重复使用的 Appbar 下。见图 3。 Appbar under reusable Appbar
在每个页面中我都使用此代码来调用 Appbar:
Widget build(BuildContext context) {
return Scaffold(
//backgroundColor: Colors.white,
appBar: AppBar(
title: ReusableBar(),
),
这是可复用AppBar的代码:
class ReusableBar extends StatelessWidget implements PreferredSizeWidget{
@override
Widget build(BuildContext context) {
//number = number + displayedText;
return AppBar(
//elevation: 0.0,
centerTitle: true,
automaticallyImplyLeading: false,
titleSpacing: 0.0,
title: Text(getTranslated(context, 'total_click:') + "$_appbarcounter"),
actions: <Widget>[
IconButton(
alignment: Alignment(0.0, -4.0),
icon: Icon(
Icons.save,
color: Colors.white,
),
onPressed: () {
// do something
//TODO AGGIUNGERE FUNZIONE AL PULSANTE SAVE CON PAGINA DI SALVATAGGIO
},
)
],
// leading: GestureDetector(
// onTap: () { /* Write listener code here */ },
// child: Icon(
// Icons.menu, // add custom icons also
// ),
// ),
);
}
【问题讨论】:
-
解决部分修改页面代码的问题。 return Scaffold( //backgroundColor: Colors.white, appBar: ReusableBar(),
标签: flutter dart flutter-appbar