Flutter自定义简单的AppBar

143 阅读1分钟
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

/// 自定义导航栏
XMAppBar(String title, String rightTitle, bool showBack,
    VoidCallback rightButtonClick) {
  return AppBar(
    centerTitle: true,
    titleSpacing: 0,
    shadowColor: Colors.white,
    leading: showBack ? BackButton() : null,
    title: Text(
      title,
      style: TextStyle(fontSize: 18),
    ),
    actions: [
      InkWell(
        onTap: rightButtonClick,
        child: Container(
          alignment: Alignment.center,
          padding: EdgeInsets.only(left: 10, right: 10),
          child: Text(
            rightTitle,
            style: TextStyle(fontSize: 16, color: Colors.black),
          ),
        ),
      )
    ],
  );
}
```
```