-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaddfarm.dart
273 lines (232 loc) · 8.33 KB
/
addfarm.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
import 'package:flutter/material.dart';
import 'dart:core';
import 'dart:convert';
import 'package:goviguru_mobile/UI/selectcrop.dart';
import 'package:goviguru_mobile/Models/user.dart';
import 'package:http/http.dart' as http;
//import 'package:goviguru_mobile/Models/farm.dart';
//import 'package:goviguru_mobile/Models/crop.dart';
class AddFarm extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Addfarm(),
);
}
}
class Addfarm extends StatefulWidget {
@override
AddfarmState createState() => AddfarmState();
}
class AddfarmState extends State <Addfarm> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
bool _autoValidate = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Add Farm"),
backgroundColor: Colors.green[700],
titleSpacing: 20,
actions: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 10.0),
child: Icon(Icons.add,size: 35.0),
),
],
),
backgroundColor: Colors.white,
body: Wrap(
children: <Widget>[
Stack(
children: <Widget>[
ClipRRect(
borderRadius:
BorderRadius.only(bottomRight: Radius.circular(300.0)),
child: Container(
color: Colors.yellow[500],
height: 80.0,
width: 100.0,
),
),
Positioned(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ClipRRect(
borderRadius: BorderRadius.only(
topRight: Radius.circular(800.0),
bottomRight: Radius.circular(900.0),
),
child: Container(
color: Colors.green[600],
height: 100.0,
width: 50.0,
),
),
],
),
),
Column(
children: <Widget>[
SizedBox(height: 25.0,),
Padding(
padding: const EdgeInsets.symmetric(horizontal:40.0,vertical:50.0),
child: Form(
key: _formKey,
autovalidate: _autoValidate,
child: Card(
elevation: 5.0,
child: Padding(
padding: EdgeInsets.fromLTRB(30.0, 30.0, 30.0, 40.0),
child: Column(
children: <Widget>[
ListTile(
title: Text("Farm 01",
style:TextStyle(fontWeight: FontWeight.w400,fontSize: 25.0,color: Colors.green[700]),
textAlign: TextAlign.center,
),
),
TextFormField(
decoration: const InputDecoration(labelText: 'Farm Name'),
//title: Text('Farms')
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 50.0, vertical: 50.0),
child: Form(
key: _formKey,
autovalidate: _autoValidate,
child: Column(
children: <Widget>[
TextFormField(
decoration: const InputDecoration(labelText: 'Farm Name'),
validator: _validateFname,
onSaved: (String value) {
},
keyboardType: TextInputType.text,
),
TextFormField(
),
TextFormField(
decoration: const InputDecoration(labelText: 'Area Name'),
validator: _validateAname,
onSaved: (String value) {
},
keyboardType: TextInputType.text,
),
TextFormField(
decoration: const InputDecoration(labelText: 'Area amount'),
validator: _validateAsq,
onSaved: (String value) {
//Farm.Asq = double.parse(value);
},
keyboardType: TextInputType.number,
),
SizedBox(height: 20.0,),
ButtonTheme(
minWidth: 100.0,
height: 50.0,
child: RaisedButton(
child: Text("Submit"),
color: Colors.green[500],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0)
),
textColor: Colors.white,
onPressed: () {},
splashColor: Colors.yellowAccent,
),
),
],
),
),
),
]
),
),
),
),
)
],
),
],
),
],
),
floatingActionButton: FloatingActionButton.extended(
icon: Icon(Icons.subdirectory_arrow_right),
label: Text("Submit All"),
backgroundColor: Colors.green[700],
onPressed: (){},
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
);
}
//Need to close all streams
void dispose(){
super.dispose();
}
//Functions for validation
String _validateFname(String value){
SizedBox(
height: 5.0,
);
RaisedButton(
child: Text('Submit'),
//onPressed: _validateFarm,
);
],
),
),
),
floatingActionButton: FloatingActionButton.extended(
icon: Icon(Icons.subdirectory_arrow_right),
label: Text('Submit All'),
backgroundColor: Colors.green[700],
onPressed: (){},
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
);
}
//Need to close all streams
void dispose(){
super.dispose();
}
//Functions for validation
String _validateFname(String value){
if(value.isEmpty){
return 'Please Enter farm Name';
}else if(value.length<2){
return 'Fill NameField';
}else{
return null;
}
}
String _validateAname(String value){
if(value.isEmpty){
return 'Please enter Area Name';
}else if(value.length<2){
return 'Please fill Area Field';
}else{
return null;
}
}
String _validateAsq(String value){
if(value.isEmpty){
return 'Please Enter Area sq';
}else if(value.length<2){
return 'Please Enter Total sq';
}else{
return null;
}
}
void _validateFarm(){
final form=_formKey.currentState;
if(form.validate()){
form.save();
}else{
setState(()=>_autoValidate=true);
}
}
}