返回按钮图片修改,statusbar字体颜色设定,appbar背景色修改,删除阴影等。
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:music_nft/views/nft_text.dart';
/// [NFTtext] 使用的是文本工具封装类,自己也可以替换。 **字体相关**
class NFTappbar extends StatelessWidget implements PreferredSizeWidget {
final Color color;
final String? title;
final List<Widget> actions;
final Brightness statusBarBrightness;
const NFTappbar({
super.key,
this.color = Colors.transparent,
this.title,
this.actions = const [],
this.statusBarBrightness = Brightness.dark,
});
@override
Widget build(BuildContext context) {
final ModalRoute<dynamic>? parentRoute = ModalRoute.of(context);
final bool canPop = parentRoute?.canPop ?? false;
return AppBar(
backgroundColor: color,
automaticallyImplyLeading: false,
shadowColor: Colors.transparent,
leading: canPop ? buildBackButton(context) : null,
title: NFTtext.semiBold(title ?? '', fontSize: 20),
actions: actions,
systemOverlayStyle:
SystemUiOverlayStyle(statusBarBrightness: statusBarBrightness),
);
}
Widget buildBackButton(BuildContext context) {
return IconButton(
splashRadius: 17,
iconSize: 17,
onPressed: () {
Navigator.maybePop(context);
},
icon: Image.asset('images/wallet/return.png'),
);
}
@override
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
}