Last active
September 13, 2019 14:00
-
-
Save d3vma/165a50f4c81fe71ad7b3e6648ba63c68 to your computer and use it in GitHub Desktop.
Custom AppBar for Flutter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>[ | |
], | |
), | |
), | |
), | |
), | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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