35 lines
980 B
Dart
35 lines
980 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|
final String title;
|
|
final List<Widget>? actions; // Optional actions (icons, buttons)
|
|
final bool showBackButton;
|
|
|
|
const CustomAppBar({
|
|
super.key,
|
|
required this.title,
|
|
this.actions,
|
|
this.showBackButton = false, // Default: No back button
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AppBar(
|
|
title: Text(title, style: const TextStyle(fontWeight: FontWeight.bold)),
|
|
centerTitle: true,
|
|
backgroundColor: Colors.blueAccent, // Customize color
|
|
elevation: 4, // Shadow effect
|
|
leading: showBackButton
|
|
? IconButton(
|
|
icon: const Icon(Icons.arrow_back),
|
|
onPressed: () => Navigator.pop(context), // Back navigation
|
|
)
|
|
: null,
|
|
actions: actions,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Size get preferredSize => const Size.fromHeight(56); // Standard AppBar height
|
|
}
|