Last active
November 26, 2019 15:42
-
-
Save pigeonflight/7869c1d995d581b331dc3fbd054cdb9e to your computer and use it in GitHub Desktop.
1 - Layout with Reusable Widget for BMI Calc
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 InputPage extends StatefulWidget { | |
@override | |
_InputPageState createState() => _InputPageState(); | |
} | |
class _InputPageState extends State<InputPage> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('BMI CALCULATOR'), | |
), | |
body: Column( | |
children: <Widget>[ | |
Expanded( | |
child: Row(children: <Widget>[ | |
ReusableWidget(colour: Color(0xff24263b)), | |
ReusableWidget(colour: Color(0xff24263b)), | |
])), | |
Expanded( | |
child: Row( | |
children: <Widget>[ | |
ReusableWidget(colour: Color(0xff24263b)), | |
], | |
), | |
), | |
Expanded( | |
child: Row( | |
children: <Widget>[ | |
ReusableWidget(colour: Color(0xff24263b)), | |
ReusableWidget( | |
colour: Color(0xff24263b), | |
), | |
], | |
), | |
), | |
], | |
), | |
); | |
} | |
} | |
class ReusableWidget extends StatelessWidget { | |
final Color colour; | |
ReusableWidget({@required this.colour}); // constructor | |
@override | |
Widget build(BuildContext context) { | |
return Expanded( | |
child: Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: Container( | |
decoration: BoxDecoration( | |
color: colour, | |
borderRadius: BorderRadius.all(Radius.circular(20.0))), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment