Skip to content

Instantly share code, notes, and snippets.

@hafizhfadh
Last active February 11, 2020 10:04
Show Gist options
  • Save hafizhfadh/26a72c0b94fb171864b1f3d63131a143 to your computer and use it in GitHub Desktop.
Save hafizhfadh/26a72c0b94fb171864b1f3d63131a143 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
class WidgetAppBar extends StatefulWidget implements PreferredSizeWidget {
final double height;
final bool automaticallyImplyLeading;
final Widget leading;
@override
final Size preferredSize;
WidgetAppBar({
Key key,
this.height,
this.leading,
this.automaticallyImplyLeading = true,
}) : preferredSize = Size.fromHeight(height != null ? height : 85),
assert(automaticallyImplyLeading != null);
@override
_WidgetAppBarState createState() => _WidgetAppBarState();
}
class _WidgetAppBarState extends State<WidgetAppBar> {
Widget backButton(canPop, leading, useCloseButton) {
if (leading == null && widget.automaticallyImplyLeading) {
if (canPop) {
return Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
GestureDetector(
child: Icon(
Icons.arrow_back_ios,
size: 30,
color: Colors.white,
),
onTap: () {
Navigator.of(context).pop();
},
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.03,
),
Image.asset(
'assets/logoTransparantBox.png',
height: 75.0,
width: 75.0,
fit: BoxFit.fill,
),
],
);
} else {
return Image.asset(
'assets/logoTransparantBox.png',
height: 75.0,
width: 75.0,
fit: BoxFit.fill,
);
}
} else {
return Image.asset(
'assets/logoTransparantBox.png',
height: 75.0,
width: 75.0,
fit: BoxFit.fill,
);
}
}
@override
Widget build(BuildContext context) {
final ModalRoute<dynamic> parentRoute = ModalRoute.of(context);
final bool canPop = parentRoute?.canPop ?? false;
final bool useCloseButton =
parentRoute is PageRoute<dynamic> && parentRoute.fullscreenDialog;
Widget leading = widget.leading;
return Container(
margin: EdgeInsets.only(bottom: 4),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Color(0xff60D6E4).withOpacity(0.40),
blurRadius: 4.0, // has the effect of softening the shadow
spreadRadius: 4.0, // has the effect of extending the shadow
offset: Offset(
0, // horizontal, move right 10
2, // vertical, move down 10
),
),
],
),
child: Container(
padding: EdgeInsets.symmetric(vertical: 4),
color: Color(0xff60D6E4),
child: SafeArea(
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
backButton(canPop, leading, useCloseButton),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text(
"ELECTRONIC SANTRI TRACKING",
style: new TextStyle(
fontSize: 15.0,
color: Colors.white,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.left,
),
Text(
"& MONITORING SYSTEM",
style: new TextStyle(
fontSize: 15.0,
color: Colors.white,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.left,
),
Text(
"Al Wafi Islamic Boarding School",
style: new TextStyle(
fontSize: 15.0,
),
textAlign: TextAlign.left,
),
],
)
],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment