Last active
December 30, 2020 13:30
-
-
Save DhrumilShah98/f934e6bf59e24e98b2e151411498d8f0 to your computer and use it in GitHub Desktop.
AppBar in 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'; | |
void main() => runApp(AppBarDemoWidget()); | |
enum MenuOptions { | |
FILTERS, | |
SETTINGS, | |
} | |
class AppBarDemoWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
title: 'AppBar Demo', | |
home: Scaffold( | |
appBar: AppBar( | |
leading: IconButton( | |
icon: Icon(Icons.menu), | |
onPressed: () { | |
//Do Something | |
}, | |
), | |
title: Text('AppBar Demo'), | |
actions: <Widget>[ | |
IconButton( | |
icon: Icon(Icons.search), | |
onPressed: () { | |
//Do something | |
}, | |
), | |
IconButton( | |
icon: Icon(Icons.shopping_cart_rounded), | |
onPressed: () { | |
//Do something | |
}, | |
), | |
PopupMenuButton( | |
offset: Offset(0, 100), | |
child: Padding( | |
padding: EdgeInsets.symmetric(horizontal: 8), | |
child: Icon(Icons.more_vert)), | |
onSelected: (MenuOptions selectedOption) { | |
//Do something | |
}, | |
itemBuilder: (context) => [ | |
PopupMenuItem( | |
child: Text('Filters'), | |
value: MenuOptions.FILTERS, | |
), | |
PopupMenuItem( | |
child: Text('Settings'), | |
value: MenuOptions.SETTINGS, | |
), | |
], | |
), | |
], | |
), | |
body: Container(), | |
), | |
); | |
} | |
} |
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'; | |
void main() => runApp(AppBarDemoWidget()); | |
enum MenuOptions{ | |
FILTERS, | |
SETTINGS | |
} | |
class AppBarDemoWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
theme: ThemeData( | |
primarySwatch: Colors.purple, | |
appBarTheme: Theme.of(context).appBarTheme.copyWith( | |
centerTitle: true, | |
elevation: 16, | |
shadowColor: Colors.black, | |
), | |
primaryTextTheme: Theme.of(context).primaryTextTheme.copyWith( | |
headline6: TextStyle( | |
fontSize: 30, | |
fontWeight: FontWeight.bold, | |
color: Colors.amber, | |
), | |
), | |
primaryIconTheme: Theme.of(context).primaryIconTheme.copyWith( | |
color: Colors.amberAccent, | |
), | |
), | |
debugShowCheckedModeBanner: false, | |
title: 'AppBar Demo App', | |
home: Scaffold( | |
appBar: AppBar( | |
leading: IconButton( | |
icon: Icon(Icons.menu), | |
onPressed: () { | |
//Do Something | |
}, | |
), | |
title: Text('AppBar Demo'), | |
actions: <Widget>[ | |
IconButton( | |
icon: Icon(Icons.search), | |
onPressed: () { | |
//Do something | |
}, | |
), | |
IconButton( | |
icon: Icon(Icons.shopping_cart_rounded), | |
onPressed: () { | |
//Do something | |
}, | |
), | |
PopupMenuButton( | |
offset: Offset(0, 100), | |
child: Padding(padding: EdgeInsets.symmetric(horizontal: 8),child: Icon(Icons.more_vert)), | |
onSelected: (MenuOptions selectedOption){ | |
//Do something | |
}, | |
itemBuilder: (context) => [ | |
PopupMenuItem( | |
child: Text('Filters'), | |
value: MenuOptions.FILTERS, | |
), | |
PopupMenuItem( | |
child: Text('Settings'), | |
value: MenuOptions.SETTINGS, | |
), | |
], | |
), | |
], | |
), | |
body: Container(), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment