Skip to content

Instantly share code, notes, and snippets.

@SuvidhaMalaviya
Created April 24, 2022 09:57
Show Gist options
  • Save SuvidhaMalaviya/8c697fb5c2ddc870f6d5aaf42f22e571 to your computer and use it in GitHub Desktop.
Save SuvidhaMalaviya/8c697fb5c2ddc870f6d5aaf42f22e571 to your computer and use it in GitHub Desktop.
Implement custom appbar with profile details inside it in flutter.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.deepPurple,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.deepPurple,
centerTitle: true,
title: Text(
'Dashboard',
style:
TextStyle(fontSize: 17, color: Colors.white, letterSpacing: 0.53),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(30),
),
),
leading: InkWell(
onTap: () {},
child: Icon(
Icons.subject,
color: Colors.white,
),
),
actions: [
InkWell(
onTap: () {},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(
Icons.notifications,
size: 20,
),
),
),
],
bottom: PreferredSize(
child: getAppBottomView(),
preferredSize: Size.fromHeight(110.0)),
),
body: Center(),
);
}
Widget getAppBottomView() {
return Container(
padding: EdgeInsets.only(left: 30, bottom: 20),
child: Row(
children: [
getProfileView(),
Container(
margin: EdgeInsets.only(left: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Hubert Wong',
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.w700,
color: Colors.white),
),
Text(
'hubert.wong@mail.com',
style: TextStyle(
fontSize: 13,
color: Colors.white,
),
),
Text(
'+1 1254 251 241',
style: TextStyle(
fontSize: 13,
color: Colors.white,
),
),
],
),
)
],
),
);
}
Widget getProfileView() {
return Stack(
children: <Widget>[
CircleAvatar(
radius: 32,
backgroundColor: Colors.white,
child: Icon(Icons.person_outline_rounded),
),
Positioned(
bottom: 1,
right: 1,
child: Container(
height: 30,
width: 30,
child: Icon(
Icons.edit,
color: Colors.deepPurple,
size: 20,
),
decoration: BoxDecoration(
color: Colors.amber,
borderRadius: BorderRadius.all(Radius.circular(20))),
))
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment