Last active
October 24, 2020 19:55
-
-
Save TobiCrackIT/e36654dd3dfdc7e1dd8d42d84ae61817 to your computer and use it in GitHub Desktop.
Custom 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'; | |
class HealthContainer extends StatelessWidget { | |
final String title; | |
final IconData icon; | |
final Color color; | |
final VoidCallback onPressed; | |
HealthContainer({this.title,this.onPressed,this.icon,this.color}); | |
@override | |
Widget build(BuildContext context) { | |
return GestureDetector( | |
onTap: ()=>onPressed(), | |
child: Container( | |
height: 80, | |
width: double.infinity, | |
decoration: BoxDecoration( | |
color: color, | |
borderRadius: BorderRadius.all(Radius.circular(3))), | |
child:Column( | |
crossAxisAlignment: CrossAxisAlignment.center, | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: [ | |
Icon(icon,color: Colors.white,), | |
Text('$title', | |
style:TextStyle( | |
fontSize: 10, | |
color: Colors.white, | |
),), | |
], | |
), | |
), | |
); | |
} | |
} | |
Padding( | |
padding: const EdgeInsets.symmetric(horizontal:8, vertical:10), | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.start, | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
Flexible( | |
child: HealthContainer( | |
color: Colors.purple, | |
icon: MdiIcons.menu, | |
title: 'First Aid', | |
), | |
), | |
SizedBox(width: 10,), | |
Flexible( | |
child: HealthContainer( | |
color: Colors.deepPurpleAccent, | |
icon: MdiIcons.menu, | |
title: 'Common Ills', | |
onPressed: () { | |
Navigator.push(context, | |
MaterialPageRoute(builder: (context) => CommonIlls())); | |
}, | |
), | |
), | |
], | |
), | |
), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment