| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- class AppTopBar extends StatelessWidget implements PreferredSizeWidget {
- final Widget? title;
- final List<Widget>? actions;
- final double? toolbarHeight;
- final PreferredSizeWidget? bottom;
- final bool? automaticallyImplyLeading;
- final int? alpha;
- final Widget? leading;
- final bool? centerTitle;
- AppTopBar(
- {super.key,
- required this.title,
- this.actions,
- this.toolbarHeight,
- this.bottom,
- this.automaticallyImplyLeading,
- this.alpha,
- this.leading, this.centerTitle,
- })
- : preferredSize =
- _PreferredAppBarSize(toolbarHeight, bottom?.preferredSize.height);
- @override
- Widget build(BuildContext context) {
- List<Widget> newActions = [];
- final actions = this.actions;
- if (actions != null) {
- for (var one in actions) {
- newActions.add(one);
- }
- }
- return Container(
- decoration: BoxDecoration(
- gradient: LinearGradient(colors: [
- context.theme.colorScheme.secondary.withAlpha(alpha ?? 255),
- context.theme.colorScheme.onSecondaryContainer.withAlpha(alpha ?? 255),
- ])),
- child: AppBar(
- title: title,
- centerTitle: centerTitle??true,
- actions: newActions,
- toolbarHeight: toolbarHeight,
- bottom: bottom,
- backgroundColor: Colors.transparent,
- foregroundColor: Colors.white,
- titleTextStyle: const TextStyle(fontSize: 19.6),
- automaticallyImplyLeading: automaticallyImplyLeading ?? false,
- leading: leading,
- ),
- );
- }
- @override
- final Size preferredSize;
- }
- class _PreferredAppBarSize extends Size {
- _PreferredAppBarSize(this.toolbarHeight, this.bottomHeight)
- : super.fromHeight(
- (toolbarHeight ?? kToolbarHeight) + (bottomHeight ?? 0));
- final double? toolbarHeight;
- final double? bottomHeight;
- }
|