Skip to content

Instantly share code, notes, and snippets.

@antklim
Created November 3, 2020 02:04
Show Gist options
  • Save antklim/990966ad8c138cc3bdadb7c57786ab1f to your computer and use it in GitHub Desktop.
Save antklim/990966ad8c138cc3bdadb7c57786ab1f to your computer and use it in GitHub Desktop.
class Operand extends StatefulWidget {
final String label;
final num initValue;
const Operand({Key key, this.label, this.initValue}) : super(key: key);
@override
_OperandState createState() => _OperandState();
}
class _OperandState extends State<Operand> {
TextEditingController controller;
@override
void initState() {
super.initState();
controller = TextEditingController(text: '${widget.initValue}');
}
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.only(top: 10, bottom: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Text(widget.label,
style: Theme.of(context).textTheme.bodyText2),
),
Flexible(
child: TextField(
controller: controller,
keyboardType: TextInputType.number,
textAlign: TextAlign.end,
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: RaisedButton(
onPressed: () {},
child: Text('From memory',
style: Theme.of(context).textTheme.button)),
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment