Skip to content

Instantly share code, notes, and snippets.

@pigeonflight
Last active November 26, 2019 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pigeonflight/7869c1d995d581b331dc3fbd054cdb9e to your computer and use it in GitHub Desktop.
Save pigeonflight/7869c1d995d581b331dc3fbd054cdb9e to your computer and use it in GitHub Desktop.
1 - Layout with Reusable Widget for BMI Calc
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