@@ -49,85 +49,83 @@ class _EditItemPageState extends State<EditItemPage> {
49
49
final l10n = AppLocalizations .of (context)! ;
50
50
final disabledColor = Theme .of (context).disabledColor;
51
51
final colors = Theme .of (context).colorScheme;
52
+ final valid = _isValid (_formKey) && _nameCon.text.isNotEmpty;
52
53
53
54
return Scaffold (
54
55
appBar: AppBar (title: Text (l10n.editItem)),
55
- body: Form (
56
- key: _formKey,
57
- child: SingleChildScrollView (
58
- child: Column (
59
- spacing: 16.0 ,
60
- children: [
61
- SizedBox .shrink (),
62
- Padding (
63
- padding: kPx,
64
- child: TextFormField (
65
- controller: _nameCon,
66
- keyboardType: TextInputType .name,
67
- decoration: InputDecoration (
68
- labelText: l10n.itemName,
69
- hintText: l10n.itemName,
56
+ body: SingleChildScrollView (
57
+ child: Container (
58
+ margin: EdgeInsets .only (bottom: kToolbarHeight * 2 ),
59
+ color: colors.surface,
60
+ child: Form (
61
+ key: _formKey,
62
+ child: Column (
63
+ spacing: 16.0 ,
64
+ children: [
65
+ SizedBox .shrink (),
66
+ Padding (
67
+ padding: kPx,
68
+ child: TextFormField (
69
+ controller: _nameCon,
70
+ keyboardType: TextInputType .name,
71
+ decoration: InputDecoration (
72
+ labelText: l10n.itemName,
73
+ hintText: l10n.itemName,
74
+ ),
75
+ onChanged: (v) => setState (() {}),
70
76
),
71
- onChanged: (v) => setState (() {}),
72
77
),
73
- ),
74
- Padding (
75
- padding: kPx,
76
- child: TextFormField (
77
- controller: _skuCon,
78
- decoration: InputDecoration (
79
- hintText: 'SKU' ,
80
- labelText: 'SKU' ,
78
+ Padding (
79
+ padding: kPx,
80
+ child: TextFormField (
81
+ controller: _skuCon,
82
+ decoration: InputDecoration (
83
+ hintText: 'SKU' ,
84
+ labelText: 'SKU' ,
85
+ ),
86
+ onChanged: (v) => setState (() {}),
81
87
),
82
- onChanged: (v) => setState (() {}),
83
88
),
84
- ),
85
- Padding (
86
- padding: kPx,
87
- child: TextFormField (
88
- controller: _priceCon,
89
- decoration: InputDecoration (
90
- labelText: l10n.price,
91
- hintText: '5.0' ,
89
+ Padding (
90
+ padding: kPx,
91
+ child: TextFormField (
92
+ controller: _priceCon,
93
+ decoration: InputDecoration (
94
+ labelText: l10n.price,
95
+ hintText: '5.0' ,
96
+ ),
97
+ keyboardType: TextInputType .number,
98
+ onChanged: (v) => setState (() {}),
92
99
),
93
- keyboardType: TextInputType .number,
94
- onChanged: (v) => setState (() {}),
95
100
),
96
- ),
97
- Padding (
98
- padding: kPx,
99
- child: TextFormField (
100
- controller: _discCon,
101
- decoration: InputDecoration (
102
- labelText: l10n.discount,
103
- hintText: '0.0' ,
101
+ Padding (
102
+ padding: kPx,
103
+ child: TextFormField (
104
+ controller: _discCon,
105
+ decoration: InputDecoration (
106
+ labelText: l10n.discount,
107
+ hintText: '0.0' ,
108
+ ),
109
+ keyboardType: TextInputType .number,
110
+ onChanged: (v) => setState (() {}),
104
111
),
105
- keyboardType: TextInputType .number,
106
- onChanged: (v) => setState (() {}),
107
112
),
108
- ),
109
- SwitchListTile . adaptive (
110
- title : Text (l10n.usePercentage) ,
111
- value : _isPercent,
112
- onChanged : (v) => setState (() => _isPercent = v ),
113
- ),
114
- const SizedBox (height : kToolbarHeight * 2 ) ,
115
- ] ,
113
+ SwitchListTile . adaptive (
114
+ title : Text (l10n.usePercentage),
115
+ value : _isPercent ,
116
+ onChanged : (v) => setState (() => _isPercent = v) ,
117
+ ),
118
+ const SizedBox . shrink ( ),
119
+ ] ,
120
+ ) ,
116
121
),
117
122
),
118
123
),
119
124
floatingActionButton: FloatingActionButton .extended (
120
- onPressed:
121
- _isValid (_formKey) && _nameCon.text.isNotEmpty
122
- ? () => _onEditItem ()
123
- : null ,
125
+ onPressed: valid ? () => _onEditItem () : null ,
124
126
disabledElevation: 0 ,
125
- backgroundColor:
126
- _nameCon.text.isNotEmpty ? colors.primaryContainer : disabledColor,
127
- foregroundColor:
128
- _nameCon.text.isNotEmpty
129
- ? colors.onPrimaryContainer
130
- : disabledColor,
127
+ backgroundColor: valid ? colors.primaryContainer : disabledColor,
128
+ foregroundColor: valid ? colors.onPrimaryContainer : disabledColor,
131
129
icon: Icon (Icons .done),
132
130
label: Text (l10n.save),
133
131
),
0 commit comments