Files
base_flutter/lib/shared/widgets/custom_app_bar.dart
2025-09-26 18:48:14 +07:00

44 lines
1.1 KiB
Dart

import 'package:flutter/material.dart';
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
const CustomAppBar({
super.key,
required this.title,
this.actions,
this.leading,
this.backgroundColor,
this.foregroundColor,
this.elevation = 0,
});
final String title;
final List<Widget>? actions;
final Widget? leading;
final Color? backgroundColor;
final Color? foregroundColor;
final double elevation;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colorScheme = theme.colorScheme;
return AppBar(
title: Text(
title,
style: theme.textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.w600,
),
),
leading: leading,
actions: actions,
elevation: elevation,
backgroundColor: backgroundColor ?? colorScheme.surfaceVariant,
foregroundColor: foregroundColor ?? colorScheme.onSurfaceVariant,
centerTitle: true,
);
}
@override
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
}