Fix bug which sometimes set an edited expense to Monthly. Fix typo in enum monthly
.
This commit is contained in:
parent
452eb73773
commit
9d478b9cbf
@ -20,7 +20,7 @@ enum Frequency {
|
||||
hint: "Twice Per Month",
|
||||
timesPerYear: 24,
|
||||
),
|
||||
montly(
|
||||
monthly(
|
||||
title: "Monthly",
|
||||
hint: "Once Per Month",
|
||||
timesPerYear: 12,
|
||||
|
@ -161,12 +161,19 @@ class _ExpenseInputDialogState extends State<ExpenseInputDialog> {
|
||||
final _expenseFormKey = GlobalKey<FormState>();
|
||||
|
||||
String _name = "";
|
||||
double _cost = 0.0;
|
||||
Frequency _freq = Frequency.montly;
|
||||
double _cost = 0;
|
||||
Frequency _freq = Frequency.monthly;
|
||||
String _desc = "";
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.expense != null) {
|
||||
_name = widget.expense!.name;
|
||||
_cost = widget.expense!.cost;
|
||||
_freq = widget.expense!.frequency;
|
||||
_desc = widget.expense!.description;
|
||||
}
|
||||
|
||||
return Column(
|
||||
// prevent AlertDialog from taking full vertical height.
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@ -206,8 +213,7 @@ class _ExpenseInputDialogState extends State<ExpenseInputDialog> {
|
||||
hintStyle: TextStyle(fontSize: 10.0),
|
||||
errorStyle: TextStyle(fontSize: 10.0),
|
||||
),
|
||||
initialValue:
|
||||
widget.expense == null ? "" : widget.expense!.name,
|
||||
initialValue: _name,
|
||||
validator: (value) {
|
||||
if (value!.isEmpty) {
|
||||
return "Name must be provided.";
|
||||
@ -229,9 +235,7 @@ class _ExpenseInputDialogState extends State<ExpenseInputDialog> {
|
||||
hintStyle: TextStyle(fontSize: 10.0),
|
||||
errorStyle: TextStyle(fontSize: 10.0),
|
||||
),
|
||||
initialValue: widget.expense == null
|
||||
? ""
|
||||
: widget.expense!.cost.toString(),
|
||||
initialValue: _cost != 0 ? _cost.toString() : "",
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return "Cost must be provided.";
|
||||
@ -273,9 +277,7 @@ class _ExpenseInputDialogState extends State<ExpenseInputDialog> {
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
value: widget.expense == null
|
||||
? Frequency.montly
|
||||
: widget.expense!.frequency,
|
||||
value: _freq,
|
||||
decoration: InputDecoration(
|
||||
labelText: "Frequency",
|
||||
errorStyle: TextStyle(fontSize: 10.0),
|
||||
@ -301,8 +303,7 @@ class _ExpenseInputDialogState extends State<ExpenseInputDialog> {
|
||||
hintStyle: TextStyle(fontSize: 10.0),
|
||||
errorStyle: TextStyle(fontSize: 10.0),
|
||||
),
|
||||
initialValue:
|
||||
widget.expense == null ? "" : widget.expense!.description,
|
||||
initialValue: _desc,
|
||||
validator: (value) {
|
||||
return null;
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user