build method
- @override
- BuildContext context,
- TimerBuilder model
override
Builds the UI according to the state in model
.
Implementation
@override
Widget build(BuildContext context, TimerBuilder model) => AlertDialog(
title: const Text("Start a timer"),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
height: 50,
width: double.infinity,
child: TextField(
controller: model.nameController,
onChanged: model.update,
decoration: const InputDecoration(hintText: "Timer Name"),
),
),
SizedBox(
height: 50,
width: double.infinity,
child: TextField(
onChanged: model.duration.update,
decoration: const InputDecoration(hintText: "Number of Minutes"),
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"\d"))],
),
),
],
),
actions: [
TextButton(child: const Text("Cancel"), onPressed: () => Navigator.of(context).pop()),
ElevatedButton(
onPressed: model.isValid ? () { model.start(); Navigator.of(context).pop(); } : null,
child: const Text("Save"),
),
],
);