Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ifarm
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TMP-2022-009
ifarm
Commits
844069e5
Commit
844069e5
authored
Nov 15, 2022
by
ayodyabanuka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated
parent
530725cc
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
253 additions
and
85 deletions
+253
-85
lib/AB/Screens/Common/Auth/Login.dart
lib/AB/Screens/Common/Auth/Login.dart
+1
-0
lib/AB/Screens/Common/Auth/register.dart
lib/AB/Screens/Common/Auth/register.dart
+4
-0
lib/AB/Screens/FoodBucket/FoodBucketList.dart
lib/AB/Screens/FoodBucket/FoodBucketList.dart
+15
-11
lib/AB/Screens/FoodBucket/SingleFoodBucketData.dart
lib/AB/Screens/FoodBucket/SingleFoodBucketData.dart
+119
-45
lib/AB/Screens/NavBar/FoodBucketSchedule.dart
lib/AB/Screens/NavBar/FoodBucketSchedule.dart
+114
-29
No files found.
lib/AB/Screens/Common/Auth/Login.dart
View file @
844069e5
...
@@ -35,6 +35,7 @@ class _LoginState extends State<Login> {
...
@@ -35,6 +35,7 @@ class _LoginState extends State<Login> {
Size
size
=
MediaQuery
.
of
(
context
).
size
;
Size
size
=
MediaQuery
.
of
(
context
).
size
;
return
Scaffold
(
return
Scaffold
(
resizeToAvoidBottomInset:
false
,
appBar:
AppBar
(
appBar:
AppBar
(
backgroundColor:
backgroundColor
,
backgroundColor:
backgroundColor
,
elevation:
0
,
elevation:
0
,
...
...
lib/AB/Screens/Common/Auth/register.dart
View file @
844069e5
...
@@ -20,6 +20,7 @@ class _registerState extends State<register> {
...
@@ -20,6 +20,7 @@ class _registerState extends State<register> {
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
Size
size
=
MediaQuery
.
of
(
context
).
size
;
Size
size
=
MediaQuery
.
of
(
context
).
size
;
return
Scaffold
(
return
Scaffold
(
resizeToAvoidBottomInset:
false
,
backgroundColor:
const
Color
(
0xff024F8E
),
backgroundColor:
const
Color
(
0xff024F8E
),
appBar:
AppBar
(
appBar:
AppBar
(
backgroundColor:
const
Color
(
0xff024F8E
),
backgroundColor:
const
Color
(
0xff024F8E
),
...
@@ -117,6 +118,9 @@ class _registerState extends State<register> {
...
@@ -117,6 +118,9 @@ class _registerState extends State<register> {
),
),
),
),
)),
)),
const
SizedBox
(
width:
20
,
),
GestureDetector
(
GestureDetector
(
onTap:
()
{
onTap:
()
{
print
(
emailController
.
text
);
print
(
emailController
.
text
);
...
...
lib/AB/Screens/FoodBucket/FoodBucketList.dart
View file @
844069e5
...
@@ -160,6 +160,7 @@ class _foodbucketsState extends State<foodbuckets> {
...
@@ -160,6 +160,7 @@ class _foodbucketsState extends State<foodbuckets> {
if
(!
mounted
)
return
;
if
(!
mounted
)
return
;
if
(
mounted
)
{
setState
(()
{
setState
(()
{
getResult
=
qrCode
;
getResult
=
qrCode
;
if
(
buckets
.
contains
(
qrCode
)
||
qrCode
==
'-1'
)
{
if
(
buckets
.
contains
(
qrCode
)
||
qrCode
==
'-1'
)
{
...
@@ -168,6 +169,7 @@ class _foodbucketsState extends State<foodbuckets> {
...
@@ -168,6 +169,7 @@ class _foodbucketsState extends State<foodbuckets> {
saveQRCodes
();
saveQRCodes
();
}
}
});
});
}
print
(
"QRCode_Result:-"
);
print
(
"QRCode_Result:-"
);
print
(
qrCode
);
print
(
qrCode
);
}
on
PlatformException
{
}
on
PlatformException
{
...
@@ -178,10 +180,12 @@ class _foodbucketsState extends State<foodbuckets> {
...
@@ -178,10 +180,12 @@ class _foodbucketsState extends State<foodbuckets> {
saveQRCodes
()
{
saveQRCodes
()
{
final
user
=
FirebaseAuth
.
instance
.
currentUser
;
final
user
=
FirebaseAuth
.
instance
.
currentUser
;
if
(
user
!=
null
)
{
if
(
user
!=
null
)
{
if
(
mounted
)
{
setState
(()
{
setState
(()
{
name
=
user
.
displayName
.
toString
();
name
=
user
.
displayName
.
toString
();
});
});
}
}
}
FirestoreServices
.
savefoodbuckets
(
buckets
,
name
);
FirestoreServices
.
savefoodbuckets
(
buckets
,
name
);
}
}
}
}
lib/AB/Screens/FoodBucket/SingleFoodBucketData.dart
View file @
844069e5
import
'dart:async'
;
import
'dart:async'
;
import
'package:firebase_database/firebase_database.dart'
;
import
'package:firebase_database/firebase_database.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:ifarm/AB/Utils/NotificationService.dart'
;
import
'package:liquid_progress_indicator/liquid_progress_indicator.dart'
;
import
'package:liquid_progress_indicator/liquid_progress_indicator.dart'
;
import
'package:switcher_button/switcher_button.dart'
;
import
'package:switcher_button/switcher_button.dart'
;
...
@@ -15,6 +16,7 @@ class SingleFoodBucketData extends StatefulWidget {
...
@@ -15,6 +16,7 @@ class SingleFoodBucketData extends StatefulWidget {
String
d
=
'100'
;
String
d
=
'100'
;
String
m
=
'250'
;
String
m
=
'250'
;
int
s
=
0
;
int
s
=
0
;
String
err
=
"2"
;
bool
svalue
=
false
;
bool
svalue
=
false
;
class
_SingleFoodBucketDataState
extends
State
<
SingleFoodBucketData
>
{
class
_SingleFoodBucketDataState
extends
State
<
SingleFoodBucketData
>
{
...
@@ -33,19 +35,29 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
...
@@ -33,19 +35,29 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
getData
();
getData
();
servovalueinbool
();
servovalueinbool
();
});
});
timer
=
Timer
.
periodic
(
const
Duration
(
seconds:
30
),
(
_
)
{
if
(
err
==
"1"
)
{
NotificationService
().
showNotification
(
1
,
"Error On Bucket"
,
"Error on bucket:
${widget.bucketId}
"
,
2
);
}
});
}
}
servovalueinbool
()
{
servovalueinbool
()
{
if
(
s
==
0
)
{
if
(
s
==
0
)
{
if
(
mounted
)
{
setState
(()
{
setState
(()
{
svalue
=
false
;
svalue
=
false
;
});
});
}
}
else
{
}
else
{
if
(
mounted
)
{
setState
(()
{
setState
(()
{
svalue
=
true
;
svalue
=
true
;
});
});
}
}
}
}
}
getData
()
{
getData
()
{
FirebaseDatabase
.
instance
FirebaseDatabase
.
instance
...
@@ -53,27 +65,44 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
...
@@ -53,27 +65,44 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
.
child
(
'Food/'
+
widget
.
bucketId
+
'/Moist/foodMoist'
)
.
child
(
'Food/'
+
widget
.
bucketId
+
'/Moist/foodMoist'
)
.
onValue
.
onValue
.
listen
((
event
)
{
.
listen
((
event
)
{
if
(
mounted
)
{
setState
(()
{
setState
(()
{
m
=
event
.
snapshot
.
value
.
toString
();
m
=
event
.
snapshot
.
value
.
toString
();
});
});
}
});
});
FirebaseDatabase
.
instance
FirebaseDatabase
.
instance
.
ref
()
.
ref
()
.
child
(
'Food/'
+
widget
.
bucketId
+
'/SERVO'
)
.
child
(
'Food/'
+
widget
.
bucketId
+
'/SERVO'
)
.
onValue
.
onValue
.
listen
((
event
)
{
.
listen
((
event
)
{
if
(
mounted
)
{
setState
(()
{
setState
(()
{
s
=
int
.
parse
(
event
.
snapshot
.
value
.
toString
());
s
=
int
.
parse
(
event
.
snapshot
.
value
.
toString
());
});
});
}
});
});
FirebaseDatabase
.
instance
FirebaseDatabase
.
instance
.
ref
()
.
ref
()
.
child
(
'Food/'
+
widget
.
bucketId
+
'/dis'
)
.
child
(
'Food/'
+
widget
.
bucketId
+
'/dis'
)
.
onValue
.
onValue
.
listen
((
event
)
{
.
listen
((
event
)
{
if
(
mounted
)
{
setState
(()
{
setState
(()
{
d
=
event
.
snapshot
.
value
.
toString
();
d
=
event
.
snapshot
.
value
.
toString
();
});
});
}
});
FirebaseDatabase
.
instance
.
ref
()
.
child
(
'Food/'
+
widget
.
bucketId
+
'/ERROR'
)
.
onValue
.
listen
((
event
)
{
if
(
mounted
)
{
setState
(()
{
err
=
event
.
snapshot
.
value
.
toString
();
});
}
});
});
}
}
...
@@ -84,8 +113,12 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
...
@@ -84,8 +113,12 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
leading:
IconButton
(
leading:
IconButton
(
icon:
const
Icon
(
Icons
.
arrow_back
,
color:
Colors
.
white
),
icon:
const
Icon
(
Icons
.
arrow_back
,
color:
Colors
.
white
),
onPressed:
()
{
onPressed:
()
{
Navigator
.
pop
(
context
);
if
(
mounted
)
{
setState
(()
{
timer
.
cancel
();
timer
.
cancel
();
});
}
Navigator
.
pop
(
context
);
},
},
),
),
backgroundColor:
const
Color
(
0xff024F8E
),
backgroundColor:
const
Color
(
0xff024F8E
),
...
@@ -101,6 +134,12 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
...
@@ -101,6 +134,12 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
const
SizedBox
(
const
SizedBox
(
height:
20
,
height:
20
,
),
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
const
Text
(
const
Text
(
'Bucket'
,
'Bucket'
,
style:
TextStyle
(
style:
TextStyle
(
...
@@ -117,6 +156,32 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
...
@@ -117,6 +156,32 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
fontFamily:
'poppins'
,
fontFamily:
'poppins'
,
),
),
),
),
],
),
Row
(
children:
[
const
Text
(
"Bucket Status"
,
style:
TextStyle
(
color:
Colors
.
white
),
),
const
SizedBox
(
width:
10
,
),
Container
(
width:
10
,
height:
10
,
decoration:
BoxDecoration
(
shape:
BoxShape
.
circle
,
color:
err
==
"2"
?
Colors
.
green
:
err
==
"1"
?
Colors
.
red
:
null
),
),
],
)
],
),
const
SizedBox
(
const
SizedBox
(
height:
30
,
height:
30
,
),
),
...
@@ -138,15 +203,21 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
...
@@ -138,15 +203,21 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
children:
[
children:
[
Text
(
Text
(
d
,
d
,
style:
const
TextStyle
(
style:
TextStyle
(
fontSize:
20
,
fontSize:
40
,
color:
Color
.
fromARGB
(
255
,
0
,
0
,
0
),
color:
int
.
parse
(
d
)
>
50
?
Colors
.
white
:
const
Color
.
fromARGB
(
255
,
0
,
0
,
0
),
fontWeight:
FontWeight
.
bold
),
fontWeight:
FontWeight
.
bold
),
),
),
const
Text
(
Text
(
'%'
,
'%'
,
style:
TextStyle
(
style:
TextStyle
(
color:
Color
.
fromARGB
(
255
,
0
,
0
,
0
),
color:
int
.
parse
(
d
)
>
50
?
Colors
.
white
:
const
Color
.
fromARGB
(
255
,
0
,
0
,
0
),
fontWeight:
FontWeight
.
bold
),
fontWeight:
FontWeight
.
bold
),
),
),
],
],
...
@@ -156,10 +227,11 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
...
@@ -156,10 +227,11 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
value:
double
.
parse
(
d
)
/
100
,
value:
double
.
parse
(
d
)
/
100
,
valueColor:
AlwaysStoppedAnimation
(
valueColor:
AlwaysStoppedAnimation
(
double
.
parse
(
d
)
>=
0.0
&&
double
.
parse
(
d
)
<=
20.0
double
.
parse
(
d
)
>=
0.0
&&
double
.
parse
(
d
)
<=
20.0
?
Color
.
fromARGB
(
255
,
255
,
0
,
0
)
?
const
Color
.
fromARGB
(
255
,
255
,
0
,
0
)
:
Colors
.
green
,
:
Colors
.
green
,
),
),
backgroundColor:
Color
.
fromARGB
(
255
,
255
,
255
,
255
),
backgroundColor:
const
Color
.
fromARGB
(
255
,
255
,
255
,
255
),
direction:
Axis
.
vertical
,
direction:
Axis
.
vertical
,
shapePath:
_buildBoatPath
(),
shapePath:
_buildBoatPath
(),
),
),
...
@@ -191,7 +263,7 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
...
@@ -191,7 +263,7 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
height:
10
,
height:
10
,
),
),
const
Text
(
const
Text
(
'
Moisture
'
,
'
Food quality
'
,
style:
TextStyle
(
style:
TextStyle
(
fontSize:
20
,
fontSize:
20
,
color:
Colors
.
white70
,
color:
Colors
.
white70
,
...
@@ -202,7 +274,7 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
...
@@ -202,7 +274,7 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
children:
[
Text
(
Text
(
m
,
int
.
parse
(
m
)
>
1
?
"Error"
:
"Good"
,
style:
const
TextStyle
(
style:
const
TextStyle
(
color:
Colors
.
white
,
color:
Colors
.
white
,
fontSize:
40
,
fontSize:
40
,
...
@@ -246,12 +318,14 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
...
@@ -246,12 +318,14 @@ class _SingleFoodBucketDataState extends State<SingleFoodBucketData> {
offColor:
Colors
.
black
,
offColor:
Colors
.
black
,
value:
svalue
,
value:
svalue
,
onChange:
(
value
)
{
onChange:
(
value
)
{
if
(
mounted
)
{
setState
(()
{
setState
(()
{
svalue
=
value
;
svalue
=
value
;
updateone
(
value
);
updateone
(
value
);
print
(
value
);
print
(
value
);
});
});
}
},
},
)
)
],
],
...
...
lib/AB/Screens/NavBar/FoodBucketSchedule.dart
View file @
844069e5
import
'package:cloud_firestore/cloud_firestore.dart'
;
import
'package:cloud_firestore/cloud_firestore.dart'
;
import
'package:cron/cron.dart'
;
import
'package:cron/cron.dart'
;
import
'package:firebase_database/firebase_database.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_datetime_picker/flutter_datetime_picker.dart'
;
import
'package:flutter_datetime_picker/flutter_datetime_picker.dart'
;
import
'package:ifarm/AB/Utils/Colors.dart'
;
import
'package:ifarm/AB/Utils/Colors.dart'
;
...
@@ -17,16 +18,15 @@ class FoodBucketSchedule extends StatefulWidget {
...
@@ -17,16 +18,15 @@ class FoodBucketSchedule extends StatefulWidget {
TextEditingController
dateController
=
TextEditingController
();
TextEditingController
dateController
=
TextEditingController
();
TextEditingController
timeController
=
TextEditingController
();
TextEditingController
timeController
=
TextEditingController
();
List
<
String
>
timeList
=
[];
List
buckets
=
[];
List
buckets
=
[];
List
bucketsMap
=
[];
List
bucketsMap
=
[];
List
<
String
>
timeList
=
[];
class
_FoodBucketScheduleState
extends
State
<
FoodBucketSchedule
>
{
class
_FoodBucketScheduleState
extends
State
<
FoodBucketSchedule
>
{
@override
@override
void
initState
()
{
void
initState
()
{
gettimelist
();
gettimelist
();
cancelSheduleTask
();
cancelSheduleTask
();
scheduleDispens
();
buckets
.
clear
();
buckets
.
clear
();
...
@@ -80,9 +80,11 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
...
@@ -80,9 +80,11 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
print
(
'change
${DateFormat('kk:mm').format(time)}
'
);
print
(
'change
${DateFormat('kk:mm').format(time)}
'
);
},
onConfirm:
(
time
)
{
},
onConfirm:
(
time
)
{
print
(
'confirm
${DateFormat('kk:mm').format(time)}
'
);
print
(
'confirm
${DateFormat('kk:mm').format(time)}
'
);
if
(
mounted
)
{
setState
(()
{
setState
(()
{
timeController
.
text
=
DateFormat
(
'kk:mm'
).
format
(
time
);
timeController
.
text
=
DateFormat
(
'kk:mm'
).
format
(
time
);
});
});
}
},
currentTime:
DateTime
.
now
(),
locale:
LocaleType
.
en
);
},
currentTime:
DateTime
.
now
(),
locale:
LocaleType
.
en
);
},
},
controller:
timeController
,
controller:
timeController
,
...
@@ -109,9 +111,11 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
...
@@ -109,9 +111,11 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
children:
[
children:
[
GestureDetector
(
GestureDetector
(
onTap:
()
{
onTap:
()
{
if
(
mounted
)
{
setState
(()
{
setState
(()
{
timeController
.
clear
();
timeController
.
clear
();
});
});
}
},
},
child:
Container
(
child:
Container
(
padding:
const
EdgeInsets
.
symmetric
(
padding:
const
EdgeInsets
.
symmetric
(
...
@@ -134,13 +138,15 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
...
@@ -134,13 +138,15 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
GestureDetector
(
GestureDetector
(
onTap:
()
{
onTap:
()
{
if
(
timeController
.
text
.
isNotEmpty
)
{
if
(
timeController
.
text
.
isNotEmpty
)
{
if
(
mounted
)
{
setState
(()
{
setState
(()
{
timeList
.
add
(
timeController
.
text
.
toString
());
timeList
.
add
(
timeController
.
text
.
toString
());
savetimelist
();
savetimelist
();
scheduleDispens
();
timeController
.
clear
();
timeController
.
clear
();
});
});
}
}
}
},
},
child:
Container
(
child:
Container
(
padding:
const
EdgeInsets
.
symmetric
(
padding:
const
EdgeInsets
.
symmetric
(
...
@@ -177,7 +183,7 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
...
@@ -177,7 +183,7 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
height:
10
,
height:
10
,
),
),
Expanded
(
Expanded
(
child:
timeList
.
isEmpty
child:
timeList
==
null
?
const
Center
(
?
const
Center
(
child:
Text
(
child:
Text
(
"No Scheduled Data"
,
"No Scheduled Data"
,
...
@@ -202,14 +208,12 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
...
@@ -202,14 +208,12 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
),
),
IconButton
(
IconButton
(
onPressed:
()
{
onPressed:
()
{
if
(
mounted
)
{
setState
(()
{
setState
(()
{
cancelSheduleTask
();
timeList
.
remove
(
timeList
[
index
]);
timeList
.
remove
(
timeList
[
index
]);
scheduleDispens
();
savetimelist
();
savetimelist
();
NotificationService
()
.
cancelNotifications
(
index
);
});
});
}
},
},
icon:
const
Icon
(
icon:
const
Icon
(
Icons
.
delete
,
Icons
.
delete
,
...
@@ -264,6 +268,52 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
...
@@ -264,6 +268,52 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
});
});
},
},
)),
)),
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceAround
,
children:
[
GestureDetector
(
onTap:
()
{
cancelSheduleTask
();
},
child:
Container
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
20
,
vertical:
10
),
decoration:
BoxDecoration
(
border:
Border
.
all
(
color:
yellowButton
),
borderRadius:
BorderRadius
.
circular
(
10
)),
height:
40
,
child:
const
Center
(
child:
Text
(
"Stop Schedule"
,
style:
TextStyle
(
color:
Colors
.
white
),
),
),
),
),
Visibility
(
visible:
timeList
!=
null
,
child:
GestureDetector
(
onTap:
()
{
scheduleDispens
();
},
child:
Container
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
20
,
vertical:
10
),
decoration:
BoxDecoration
(
color:
yellowButton
,
borderRadius:
BorderRadius
.
circular
(
10
)),
height:
40
,
child:
const
Center
(
child:
Text
(
"Schedule Start"
,
style:
TextStyle
(
color:
Colors
.
black
),
),
),
),
),
),
],
)
)
],
],
),
),
...
@@ -271,27 +321,61 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
...
@@ -271,27 +321,61 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
}
}
scheduleDispens
()
async
{
scheduleDispens
()
async
{
if
(
timeList
.
isEmpty
)
{
if
(
timeList
==
null
)
{
cancelSheduleTask
();
cancelSheduleTask
();
NotificationService
().
cancelAllNotifications
();
NotificationService
().
cancelAllNotifications
();
}
else
{
}
else
{
print
(
timeList
);
print
(
DateFormat
(
'kk:mm'
).
format
(
DateTime
.
now
()));
for
(
var
i
=
0
;
i
<
timeList
.
length
;
i
++)
{
for
(
var
i
=
0
;
i
<
timeList
.
length
;
i
++)
{
String
hours
=
timeList
[
i
].
toString
().
substring
(
0
,
2
);
String
hours
=
timeList
[
i
].
toString
().
substring
(
0
,
2
);
String
mins
=
timeList
[
i
].
toString
().
substring
(
3
,
5
);
String
mins
=
timeList
[
i
].
toString
().
substring
(
3
,
5
);
scheduledTask
=
scheduledTask
=
cron
.
schedule
(
Schedule
.
parse
(
"*/
$mins
*/
$hours
* * *"
),
()
async
{
cron
.
schedule
(
Schedule
.
parse
(
"*/
$mins
*/
$hours
* * *"
),
()
async
{
final
servoref1
=
FirebaseDatabase
.
instance
.
ref
();
for
(
var
k
=
0
;
k
<
buckets
.
length
;
k
++)
{
print
(
"servo run"
);
servoref1
.
update
({
"Food/"
+
buckets
[
k
]
+
"/SERVO"
:
1
,
});
Future
.
delayed
(
const
Duration
(
seconds:
20
),
()
async
{
print
(
"servo closed"
);
await
servoref1
.
update
({
"Food/"
+
buckets
[
k
]
+
"/SERVO"
:
0
,
});
});
}
NotificationService
().
showNotification
(
NotificationService
().
showNotification
(
i
,
1
,
"Food Dispensing"
,
"Food Dispensing"
,
"Food dispensing now
${DateFormat('kk:mm').format(DateTime.now()).toString()}
"
,
"Food dispensing now
${DateFormat('kk:mm').format(DateTime.now()).toString()}
"
,
1
);
1
);
});
});
print
(
hours
+
mins
);
print
(
hours
+
mins
);
}
}
print
(
"start"
);
print
(
"start"
);
}
}
}
}
dispense
()
async
{
print
(
'start dispensing'
);
for
(
var
k
=
0
;
k
<
buckets
.
length
;
k
++)
{
final
servoref1
=
FirebaseDatabase
.
instance
.
ref
();
print
(
"servo run"
);
servoref1
.
update
({
"Food/"
+
buckets
[
k
]
+
"/SERVO"
:
1
,
});
Future
.
delayed
(
const
Duration
(
seconds:
20
),
()
async
{
await
servoref1
.
update
({
"Food/"
+
buckets
[
k
]
+
"/SERVO"
:
0
,
});
});
}
}
void
cancelSheduleTask
()
async
{
void
cancelSheduleTask
()
async
{
if
(
scheduledTask
!=
null
)
{
if
(
scheduledTask
!=
null
)
{
scheduledTask
.
cancel
();
scheduledTask
.
cancel
();
...
@@ -308,9 +392,10 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
...
@@ -308,9 +392,10 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
gettimelist
()
async
{
gettimelist
()
async
{
SharedPreferences
timelist
=
await
SharedPreferences
.
getInstance
();
SharedPreferences
timelist
=
await
SharedPreferences
.
getInstance
();
if
(
mounted
)
{
setState
(()
{
setState
(()
{
timeList
=
timelist
.
getStringList
(
"timelist"
);
timeList
=
timelist
.
getStringList
(
"timelist"
);
scheduleDispens
();
});
});
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment