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? 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); }