Skip to content

Instantly share code, notes, and snippets.

@d3vma
Last active September 13, 2019 14:00
Show Gist options
  • Save d3vma/165a50f4c81fe71ad7b3e6648ba63c68 to your computer and use it in GitHub Desktop.
Save d3vma/165a50f4c81fe71ad7b3e6648ba63c68 to your computer and use it in GitHub Desktop.
Custom AppBar for Flutter
import 'package:flutter/material.dart';
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
final Widget title;
final Widget leading;
@override
Size get preferredSize => new Size.fromHeight(kToolbarHeight);
const CustomAppBar({Key key, this.title, this.leading}) : super(key: key);
noSuchMethod(Invocation i) => super.noSuchMethod(i);
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return AppBar(
leading: leading,
titleSpacing: 0,
title: title,
centerTitle: false,
elevation: 0,
bottom: PreferredSize(
preferredSize: Size.fromHeight(70),
child: Container(
color: theme.primaryColor,
child: Padding(
padding: EdgeInsets.all(0.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
],
),
),
),
),
);
}
}
appBar: CustomAppBar(
title: Text('Back'),
leading: IconButton(
icon: Icon(Icons.arrow_back_ios),
onPressed: () => Navigator.of(context).maybePop(),
tooltip: MaterialLocalizations.of(context).backButtonTooltip,
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment