Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-035-CoviDefender
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
2021-035
2021-035-CoviDefender
Commits
f2944e44
Commit
f2944e44
authored
Aug 13, 2021
by
duranka-kads
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
router final update
parent
15008cc1
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
3108 additions
and
253 deletions
+3108
-253
android/app/src/main/AndroidManifest.xml
android/app/src/main/AndroidManifest.xml
+4
-0
lib/EAnalyzer/AddLocation.dart
lib/EAnalyzer/AddLocation.dart
+236
-245
lib/SRouter/MapDesignPage.dart
lib/SRouter/MapDesignPage.dart
+1375
-0
lib/SRouter/dialogbox.dart
lib/SRouter/dialogbox.dart
+64
-0
lib/SRouter/safeRoute.dart
lib/SRouter/safeRoute.dart
+992
-0
lib/SRouter/secrectMapKey.dart
lib/SRouter/secrectMapKey.dart
+4
-0
lib/SRouter/srouterDashboard.dart
lib/SRouter/srouterDashboard.dart
+247
-0
lib/SRouter/widgets/alertDialogBox.dart
lib/SRouter/widgets/alertDialogBox.dart
+55
-0
lib/home_screen.dart
lib/home_screen.dart
+13
-7
pubspec.lock
pubspec.lock
+113
-1
pubspec.yaml
pubspec.yaml
+5
-0
No files found.
android/app/src/main/AndroidManifest.xml
View file @
f2944e44
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.example.covidefender"
>
<uses-permission
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<application
android:label=
"covidefender"
android:icon=
"@mipmap/ic_launcher"
>
<meta-data
android:name=
"com.google.android.geo.API_KEY"
android:value=
"AIzaSyBuDih9ioyQAR9ikg3zEoE_5mhXvZh5oAw"
/>
<activity
android:name=
".MainActivity"
android:launchMode=
"singleTop"
...
...
lib/EAnalyzer/AddLocation.dart
View file @
f2944e44
...
...
@@ -7,215 +7,216 @@ class AddLocation extends StatefulWidget {
}
class
AddLocationState
extends
State
<
AddLocation
>
{
String
userName
;
String
phoneNumber
;
String
riskLocation
;
String
hotelName
;
String
date
;
String
time
;
getUserName
(
name
)
{
this
.
userName
=
name
;
}
String
userName
;
String
phoneNumber
;
String
riskLocation
;
String
hotelName
;
String
date
;
String
time
;
getUserName
(
name
){
this
.
userName
=
name
;
}
getPhoneNumber
(
pno
)
{
this
.
phoneNumber
=
pno
;
}
getPhoneNumber
(
pno
)
{
this
.
phoneNumber
=
pno
;
}
getRiskLocation
(
location
)
{
this
.
riskLocation
=
location
;
}
getRiskLocation
(
location
)
{
this
.
riskLocation
=
location
;
}
getHotelName
(
hotelname
)
{
this
.
hotelName
=
hotelname
;
}
getHotelName
(
hotelname
)
{
this
.
hotelName
=
hotelnam
e
;
}
getDate
(
date
)
{
this
.
date
=
dat
e
;
}
getDate
(
date
)
{
this
.
date
=
dat
e
;
}
getTime
(
time
)
{
this
.
time
=
tim
e
;
}
getTime
(
time
){
this
.
time
=
time
;
}
//---------------------------------------------Create Data-----------------------------------------------------
createData
()
{
print
(
"object"
);
DocumentReference
documentReference
=
Firestore
.
instance
.
collection
(
"RiskLocation"
).
document
(
userName
);
Map
<
String
,
dynamic
>
locations
={
"userName"
:
userName
,
"phoneNumber"
:
phoneNumber
,
"riskLocation"
:
riskLocation
,
"hotelName"
:
hotelName
,
"date"
:
dat
e
,
"time"
:
time
};
documentReference
.
setData
(
locations
).
whenComplete
(()
{
print
(
"
$userName
created"
);
}
);
}
createData
()
{
print
(
"object"
);
DocumentReference
documentReference
=
Firestore
.
instance
.
collection
(
"RiskLocation"
).
document
(
userName
);
Map
<
String
,
dynamic
>
locations
=
{
"userName"
:
userName
,
"phoneNumber"
:
phoneNumber
,
"riskLocation"
:
riskLocation
,
"hotelName"
:
hotelNam
e
,
"date"
:
date
,
"time"
:
time
};
documentReference
.
setData
(
locations
).
whenComplete
(()
{
print
(
"
$userName
created"
);
});
}
//---------------------------------------------Read Data-----------------------------------------------------
readData
()
{
DocumentReference
documentReference
=
Firestore
.
instance
.
collection
(
"RiskLocation"
).
document
(
userName
);
readData
(){
DocumentReference
documentReference
=
Firestore
.
instance
.
collection
(
"RiskLocation"
).
document
(
userName
);
documentReference
.
get
().
then
((
datasnapshot
){
documentReference
.
get
().
then
((
datasnapshot
)
{
print
(
datasnapshot
.
data
()[
"userName"
]);
print
(
datasnapshot
.
data
()[
"phoneNumber"
]);
print
(
datasnapshot
.
data
()[
"riskLocation"
]);
print
(
datasnapshot
.
data
()[
"hotelName"
]);
print
(
datasnapshot
.
data
()[
"date"
]);
print
(
datasnapshot
.
data
()[
"time"
]);
});
}
});
}
//---------------------------------------------Update Data-----------------------------------------------------
updateData
()
{
print
(
"object"
);
updateData
()
{
print
(
"object"
);
DocumentReference
documentReference
=
Firestore
.
instance
.
collection
(
"RiskLocation"
).
document
(
userName
);
DocumentReference
documentReference
=
Firestore
.
instance
.
collection
(
"RiskLocation"
).
document
(
userName
);
Map
<
String
,
dynamic
>
locations
=
{
"userName"
:
userName
,
"phoneNumber"
:
phoneNumber
,
"riskLocation"
:
riskLocation
,
"hotelName"
:
hotelName
,
"date"
:
date
,
"time"
:
time
};
Map
<
String
,
dynamic
>
locations
=
{
"userName"
:
userName
,
"phoneNumber"
:
phoneNumber
,
"riskLocation"
:
riskLocation
,
"hotelName"
:
hotelName
,
"date"
:
date
,
"time"
:
time
};
documentReference
.
setData
(
locations
).
whenComplete
(()
{
print
(
"
$userName
Updated"
);
});
}
documentReference
.
setData
(
locations
).
whenComplete
(()
{
print
(
"
$userName
Updated"
);
});
}
//---------------------------------------------Delete Data-----------------------------------------------------
deleteData
(){
DocumentReference
documentReference
=
Firestore
.
instance
.
collection
(
"RiskLocation"
).
document
(
userName
);
documentReference
.
delete
().
whenComplete
((){
print
(
"
$userName
Deleted"
);
});
}
deleteData
()
{
DocumentReference
documentReference
=
Firestore
.
instance
.
collection
(
"RiskLocation"
).
document
(
userName
);
documentReference
.
delete
().
whenComplete
(()
{
print
(
"
$userName
Deleted"
);
});
}
final
GlobalKey
<
FormState
>
_formKey
=
GlobalKey
<
FormState
>();
final
GlobalKey
<
FormState
>
_formKey
=
GlobalKey
<
FormState
>();
//---------------------------------------------User Name-----------------------------------------------------
Widget
_buildName
(
)
{
return
TextFormField
(
decoration:
InputDecoration
(
labelText:
'Full Name'
),
validator:
(
String
value
)
{
if
(
value
.
isEmpty
)
{
return
'*Full Name is Required'
;
}
},
// onSaved: (String value){
// _fName = value;
// },
onChanged:
(
String
name
)
{
getUserName
(
name
);
},
);
}
Widget
_buildName
()
{
return
TextFormField
(
decoration:
InputDecoration
(
labelText:
'Full Name'
),
validator:
(
String
value
)
{
if
(
value
.
isEmpty
)
{
return
'*Full Name is Required'
;
}
},
// onSaved: (String value){
// _fName = value;
// },
onChanged:
(
String
name
)
{
getUserName
(
name
);
},
);
}
//---------------------------------------------Phone Number-----------------------------------------------------
Widget
_buildPNo
(
)
{
return
TextFormField
(
decoration:
InputDecoration
(
labelText:
'Phone Number'
),
keyboardType:
TextInputType
.
phone
,
maxLength:
10
,
validator:
(
String
value
)
{
if
(
value
.
isEmpty
)
{
return
'*Phone Number is Required'
;
}
},
// onSaved: (String value){
// _lName = value;
// },
onChanged:
(
String
id
)
{
getPhoneNumber
(
phoneNumber
);
},
);
}
Widget
_buildPNo
()
{
return
TextFormField
(
decoration:
InputDecoration
(
labelText:
'Phone Number'
),
keyboardType:
TextInputType
.
phone
,
maxLength:
10
,
validator:
(
String
value
)
{
if
(
value
.
isEmpty
)
{
return
'*Phone Number is Required'
;
}
},
// onSaved: (String value){
// _lName = value;
// },
onChanged:
(
String
id
)
{
getPhoneNumber
(
phoneNumber
);
},
);
}
//---------------------------------------------Risk Location-----------------------------------------------------
Widget
_buildLocation
(
)
{
return
TextFormField
(
decoration:
InputDecoration
(
labelText:
'Risk Location'
),
validator:
(
String
value
)
{
if
(
value
.
isEmpty
)
{
return
'*Risk Location is Required'
;
}
},
// onSaved: (String value){
// _age = value;
// },
onChanged:
(
String
riskLocation
)
{
getRiskLocation
(
riskLocation
);
},
);
}
Widget
_buildLocation
()
{
return
TextFormField
(
decoration:
InputDecoration
(
labelText:
'Risk Location'
),
validator:
(
String
value
)
{
if
(
value
.
isEmpty
)
{
return
'*Risk Location is Required'
;
}
},
// onSaved: (String value){
// _age = value;
// },
onChanged:
(
String
riskLocation
)
{
getRiskLocation
(
riskLocation
);
},
);
}
//---------------------------------------------Hotel Name-----------------------------------------------------
Widget
_buildHotelName
(
)
{
return
TextFormField
(
decoration:
InputDecoration
(
labelText:
'Hotel Name'
),
validator:
(
String
value
)
{
if
(
value
.
isEmpty
)
{
return
'*Hotel Name is Required'
;
}
},
// onSaved: (String value){
// _address = value;
// },
onChanged:
(
String
hotelName
)
{
getHotelName
(
hotelName
);
},
);
}
Widget
_buildHotelName
()
{
return
TextFormField
(
decoration:
InputDecoration
(
labelText:
'Hotel Name'
),
validator:
(
String
value
)
{
if
(
value
.
isEmpty
)
{
return
'*Hotel Name is Required'
;
}
},
// onSaved: (String value){
// _address = value;
// },
onChanged:
(
String
hotelName
)
{
getHotelName
(
hotelName
);
},
);
}
//---------------------------------------------Date-----------------------------------------------------
Widget
_buildDate
(
)
{
return
TextFormField
(
decoration:
InputDecoration
(
labelText:
'Date'
),
validator:
(
String
value
)
{
if
(
value
.
isEmpty
)
{
return
'*Date is Required'
;
}
},
// onSaved: (String value){
// _nic = value;
// },
onChanged:
(
String
date
)
{
getDate
(
date
);
},
);
}
Widget
_buildDate
()
{
return
TextFormField
(
decoration:
InputDecoration
(
labelText:
'Date'
),
validator:
(
String
value
)
{
if
(
value
.
isEmpty
)
{
return
'*Date is Required'
;
}
},
// onSaved: (String value){
// _nic = value;
// },
onChanged:
(
String
date
)
{
getDate
(
date
);
},
);
}
//---------------------------------------------Time-----------------------------------------------------
Widget
_buildTime
(
){
return
TextFormField
(
decoration:
InputDecoration
(
labelText:
'Time'
),
validator:
(
String
value
){
if
(
value
.
isEmpty
)
{
return
'*Time is Required'
;
}
},
// onSaved: (String value){
// _phoneNumber = value;
// },
onChanged:
(
String
time
){
getTime
(
time
);
},
);
}
Widget
_buildTime
()
{
return
TextFormField
(
decoration:
InputDecoration
(
labelText:
'Time'
),
validator:
(
String
value
)
{
if
(
value
.
isEmpty
)
{
return
'*Time is Required'
;
}
},
// onSaved: (String value){
// _phoneNumber = value;
// },
onChanged:
(
String
time
)
{
getTime
(
time
);
},
);
}
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -226,84 +227,74 @@ Widget _buildTime(){
title:
Text
(
"Add Risk Location"
),
),
body:
Container
(
margin:
EdgeInsets
.
all
(
24
),
margin:
EdgeInsets
.
all
(
24
),
child:
Form
(
key:
_formKey
,
child:
ListView
(
scrollDirection:
Axis
.
vertical
,
//mainAxisAlignment: MainAxisAlignment.center,
children:
<
Widget
>[
_buildName
(),
_buildPNo
(),
_buildLocation
(),
_buildHotelName
(),
_buildDate
(),
_buildTime
(),
SizedBox
(
height:
100
),
RaisedButton
(
color:
Colors
.
green
,
child:
Text
(
'Submit'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
18
),
),
onPressed:
()
{
if
(!
_formKey
.
currentState
.
validate
())
{
return
;
}
createData
();
}
,
),
// RaisedButton(
// color: Colors.blue,
// child: Text(
// 'View',
// style: TextStyle(color: Colors.white, fontSize: 18),
// ),
// onPressed: () {
// readData();
// } ,
// ),
RaisedButton
(
color:
Colors
.
yellowAccent
[
700
],
child:
Text
(
'Update'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
18
),
),
onPressed:
()
{
updateData
();
}
,
),
RaisedButton
(
color:
Colors
.
red
,
child:
Text
(
'Delete'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
18
),
),
onPressed:
()
{
deleteData
();
}
,
),
],
),),
//mainAxisAlignment: MainAxisAlignment.center,
children:
<
Widget
>[
_buildName
(),
_buildPNo
(),
_buildLocation
(),
_buildHotelName
(),
_buildDate
(),
_buildTime
(),
SizedBox
(
height:
100
),
RaisedButton
(
color:
Colors
.
green
,
child:
Text
(
'Submit'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
18
),
),
onPressed:
()
{
if
(!
_formKey
.
currentState
.
validate
())
{
return
;
}
createData
();
},
),
// RaisedButton(
// color: Colors.blue,
// child: Text(
// 'View',
// style: TextStyle(color: Colors.white, fontSize: 18),
// ),
// onPressed: () {
// readData();
// } ,
// ),
RaisedButton
(
color:
Colors
.
yellowAccent
[
700
],
child:
Text
(
'Update'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
18
),
),
onPressed:
()
{
updateData
();
},
),
RaisedButton
(
color:
Colors
.
red
,
child:
Text
(
'Delete'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
18
),
),
onPressed:
()
{
deleteData
();
},
),
],
),
),
),
);
}
}
\ No newline at end of file
}
lib/SRouter/MapDesignPage.dart
0 → 100644
View file @
f2944e44
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:google_maps_flutter/google_maps_flutter.dart'
;
import
'package:font_awesome_flutter/font_awesome_flutter.dart'
;
import
'package:cloud_firestore/cloud_firestore.dart'
;
class
MapDesignPage
extends
StatefulWidget
{
@override
MapDesignPageState
createState
()
=>
MapDesignPageState
();
}
class
MapDesignPageState
extends
State
<
MapDesignPage
>
{
Completer
<
GoogleMapController
>
_controller
=
Completer
();
Future
_data
;
var
riskList
=
[];
// String colomboRL = '0';
// var galleRL = '0';
//var ampareRL = '0';
String
ampareRL
=
'0'
;
String
anuradhapuraRL
=
'0'
;
String
badullaRL
=
'0'
;
String
batticaloaRL
=
'0'
;
String
colomboRL
=
'0'
;
String
galleRL
=
'0'
;
String
gampahaRL
=
'0'
;
String
hambantotaRL
=
'0'
;
String
jaffnaRL
=
'0'
;
String
kalmunaiRL
=
'0'
;
String
kalutaraRL
=
'0'
;
String
kandyRL
=
'0'
;
String
kegalleRL
=
'0'
;
String
kilinochchiRL
=
'0'
;
String
kurunagalaRL
=
'0'
;
String
mannarRL
=
'0'
;
String
mataleRL
=
'0'
;
String
mataraRL
=
'0'
;
String
monaragalaRL
=
'0'
;
String
mullaitivuRL
=
'0'
;
String
nuwaraEliyaRL
=
'0'
;
String
polonnaruwaRL
=
'0'
;
String
puttalamRL
=
'0'
;
String
ratnapuraRL
=
'0'
;
String
trincomaleeRL
=
'0'
;
String
vavuniyaRL
=
'0'
;
//Key mapKey = UniqueKey();
BitmapDescriptor
colomboIcon
=
BitmapDescriptor
.
defaultMarkerWithHue
(
BitmapDescriptor
.
hueRed
,
);
/* Future _readData() async {
var firestore = Firestore.instance;
QuerySnapshot qn = await firestore.collection("RiskLevel").getDocuments();
print(qn.documents[0].data());
//print(qn.documents[1].data());
for (int no = 0; no < 26; no++) {
riskList.add(qn.documents[no].data());
}
print(riskList);
print('yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy');
print(riskList[17]);
}*/
@override
void
initState
()
{
super
.
initState
();
_data
=
_readData
();
// print('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
}
final
FirebaseFirestore
firestore
=
FirebaseFirestore
.
instance
;
Future
_readData
()
async
{
//DocumentReference documentReference = Firestore.instance.collection("RiskLocation").document('');
DocumentSnapshot
documentSnapshot
;
try
{
/* documentSnapshot = await firestore
.collection('RiskLevel')
.document('Gampaha_2021-06-30')
.get();*/
documentSnapshot
=
// ignore: missing_return
await
firestore
.
collection
(
"RiskLevel"
)
.
orderBy
(
"date"
,
descending:
true
)
.
get
()
// ignore: missing_return
.
then
((
querySnapshot
)
{
querySnapshot
.
docs
.
forEach
((
result
)
{
print
(
result
.
data
());
setState
(()
{
riskList
.
add
(
result
.
data
());
});
// print(querySnapshot.docs);
// print(querySnapshot.docs[0]);
});
// print(riskList[4]);
//print('ddddddddddddddddddddddddddddddddddddddddddddddddddddddd');
print
(
riskList
);
// return documentSnapshot;
});
/* print('documentSnapshot.data.toString()');
print(documentSnapshot.data.toString());
print(documentSnapshot.get('cases'));
print(documentSnapshot.data()['riskLevel']);*/
// print(documentSnapshot);
}
catch
(
e
)
{
print
(
e
);
}
}
double
zoomVal
=
5.0
;
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
backwardsCompatibility:
false
,
backgroundColor:
Colors
.
blueAccent
.
shade700
,
title:
Text
(
"Sri Lanka"
),
),
body:
Stack
(
children:
<
Widget
>[
_buildContainer
(),
_buildGoogleMap
(
context
),
_zoomminusfunction
(),
_zoomplusfunction
(),
_buildContainer
(),
],
),
);
}
Widget
_zoomminusfunction
()
{
return
Align
(
alignment:
Alignment
.
topLeft
,
child:
IconButton
(
icon:
Icon
(
FontAwesomeIcons
.
searchMinus
,
color:
Color
(
0xff6200ee
)),
onPressed:
()
{
zoomVal
--;
_minus
(
zoomVal
);
}),
);
}
Widget
_zoomplusfunction
()
{
return
Align
(
alignment:
Alignment
.
topRight
,
child:
IconButton
(
icon:
Icon
(
FontAwesomeIcons
.
searchPlus
,
color:
Color
(
0xff6200ee
)),
onPressed:
()
{
zoomVal
++;
_plus
(
zoomVal
);
}),
);
}
Future
<
void
>
_minus
(
double
zoomVal
)
async
{
final
GoogleMapController
controller
=
await
_controller
.
future
;
controller
.
animateCamera
(
CameraUpdate
.
newCameraPosition
(
CameraPosition
(
target:
LatLng
(
7.8731
,
80.7718
),
zoom:
zoomVal
)));
}
Future
<
void
>
_plus
(
double
zoomVal
)
async
{
final
GoogleMapController
controller
=
await
_controller
.
future
;
controller
.
animateCamera
(
CameraUpdate
.
newCameraPosition
(
CameraPosition
(
target:
LatLng
(
7.8731
,
80.7718
),
zoom:
zoomVal
)));
}
var
name
=
[];
Widget
_buildContainer
()
{
return
Align
(
alignment:
Alignment
.
bottomLeft
,
child:
Container
(
margin:
EdgeInsets
.
symmetric
(
vertical:
20.0
),
height:
150.0
,
child:
ListView
(
scrollDirection:
Axis
.
horizontal
,
children:
<
Widget
>[
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://media-cdn.tripadvisor.com/media/photo-s/05/c0/c0/b1/buddhangala-monastery.jpg"
,
7.3018
,
81.6747
,
"Ampara"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
25
])),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://www.beautifulday.photography/img/s/v-10/p2915189545-3.jpg"
,
8.3114
,
80.4037
,
"Anuradhapura"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
24
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://media-cdn.tripadvisor.com/media/photo-s/17/0b/d7/e7/dunhinda-falls-is-a-waterfall.jpg"
,
6.9934
,
81.0550
,
"Badulla"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
23
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://www.lovesrilanka.org/wp-content/uploads/2020/04/LS_BLOG27_C1_800x520.jpg"
,
7.7310
,
81.6747
,
"Batticaloa"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
22
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://sprudge.com/wp-content/uploads/2020/01/colombo-sklyine-4-Colombo.jpg"
,
6.9271
,
79.8612
,
"Colombo"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
21
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://img.traveltriangle.com/blog/wp-content/uploads/2019/08/shutterstock_599364767.jpg"
,
6.0535
,
80.2210
,
"Galle"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
20
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://upload.wikimedia.org/wikipedia/commons/thumb/0/08/PSX_20190611_112013.jpg/1200px-PSX_20190611_112013.jpg"
,
7.0840
,
80.0098
,
"Gampaha"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
19
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQJ0N-JsypZJa5bVi-YRGn8wbVf7ehzvu0NvQ&usqp=CAU"
,
6.1429
,
81.1212
,
"Hambantota"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
18
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTFvNDtyFYB52eUau9Xpt95Go1oiXSxYdK87A&usqp=CAU"
,
9.6615
,
80.0255
,
"Jaffna"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
17
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://www.holidify.com/images/bgImages/KALMUNAI.jpg"
,
7.4144
,
81.8306
,
"Kalmunai"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
16
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://i.pinimg.com/originals/30/ab/6b/30ab6b2a15b944a94c2947a7eaa6d077.jpg"
,
6.5854
,
79.9607
,
"Kalutara"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
15
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://deih43ym53wif.cloudfront.net/temple-tooth-kandy-sri-lanka-shutterstock_1037797372_24beb3388c.jpeg"
,
7.2906
,
80.6337
,
"Kandy"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
14
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://tour.lk/uploads/image-slider-1_aZyGzTVf8m.jpg"
,
7.2513
,
80.3464
,
"Kegalle"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
13
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://a0.muscache.com/im/pictures/4d03103e-be4e-4f98-b3cb-2c93cc3e5a69.jpg?im_w=720"
,
9.3803
,
80.3770
,
"Kilinochchi"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
12
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://lh3.googleusercontent.com/proxy/4lJEUjq8w-sw_LooTY1bHG63rMZYlKKkusbahIx4048TcY-VBxRlkykpKBvLrcWUxaQA655UqKhzrkQcGfZZ_0S_X8SzFbJL2iqMLr_DS_Rgict2lWsDsT4fe86x6BrA"
,
7.4818
,
80.3609
,
"Kurunagala"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
11
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"http://2.bp.blogspot.com/-nkNGsHbUmO4/UdeIWeUQ2eI/AAAAAAAAAFY/vg_kz4inal8/s1600/Adam_Bridge.jpg"
,
8.9810
,
79.9044
,
"Mannar"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
10
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://i.pinimg.com/originals/d4/f5/7a/d4f57a953657679491b8c0a9b17e6b67.jpg"
,
7.4675
,
80.6234
,
"Matale"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
9
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://i.ytimg.com/vi/cXKMMjWifaw/maxresdefault.jpg"
,
5.9549
,
80.5550
,
"Matara"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
8
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTnyn8Nbn1UAF2lgZhmPiraxdcSrOmGGZXR45sTFVToZsdQ80FTQXB8XaMvxD3T6lEkm0s&usqp=CAU"
,
6.8728
,
81.3507
,
"Monaragala"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
7
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://tour.lk/uploads/image-slider-15sad_PJbiME6ty3.jpg"
,
9.2671
,
80.8142
,
"Mullaitivu"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
6
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://hare-media-cdn.tripadvisor.com/media/attractions-splice-spp-674x446/07/7b/c0/1e.jpg"
,
6.9497
,
80.7891
,
"Nuwara Eliya"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
5
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://www.destguides.com/dynamic-files/itinerarystop/5722/background-image.jpg"
,
7.9403
,
81.0188
,
"Polonnaruwa"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
4
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://d27k8xmh3cuzik.cloudfront.net/wp-content/uploads/2019/01/OG-Puttalam-Places-To-Visitepb0310.jpg"
,
8.0408
,
79.8394
,
"Puttalam"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
3
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://media.timeout.com/images/102153093/630/472/image.jpg"
,
6.7056
,
80.3847
,
"Ratnapura"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
2
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://tuktukdude.com/wp-content/uploads/2019/07/shutterstock_597005744-e1515476269187-1-2000x1500.jpg"
,
8.5874
,
81.2152
,
"Trincomalee"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
1
]),
),
SizedBox
(
width:
9.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
_boxes
(
"https://d27k8xmh3cuzik.cloudfront.net/wp-content/uploads/2014/11/og-for-Places-To-Visit-In-Vavuniya.jpg"
,
8.7542
,
80.4982
,
"Vavuniya"
,
riskList
.
isEmpty
?
{
'date'
:
''
,
'district'
:
''
,
'riskLevel'
:
''
,
'cases'
:
''
}
:
riskList
[
0
]),
),
],
),
),
);
}
Widget
_boxes
(
String
_image
,
double
lat
,
double
long
,
String
districtName
,
Object
data
)
{
return
GestureDetector
(
onTap:
()
{
// mapKey = UniqueKey();
_gotoLocation
(
lat
,
long
);
},
child:
Container
(
child:
new
FittedBox
(
child:
Material
(
color:
Colors
.
white
,
elevation:
14.0
,
borderRadius:
BorderRadius
.
circular
(
24.0
),
shadowColor:
Color
(
0x802196F3
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
<
Widget
>[
Container
(
width:
180
,
height:
200
,
child:
ClipRRect
(
borderRadius:
new
BorderRadius
.
circular
(
24.0
),
child:
Image
(
fit:
BoxFit
.
fill
,
image:
NetworkImage
(
_image
),
),
),
),
Container
(
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
cardInfoContainer
(
districtName
,
data
),
),
),
],
)),
),
),
);
}
Widget
cardInfoContainer
(
String
districtName
,
Object
data
)
{
// print("........................................................");
var
rlevel
=
""
;
var
map
=
Map
<
String
,
dynamic
>.
from
(
data
);
if
(
map
[
'riskLevel'
].
toString
()
==
'0'
&&
map
[
'riskLevel'
].
toString
().
isNotEmpty
)
{
rlevel
=
'Risk of COVID19 is low'
;
}
if
(
map
[
'riskLevel'
].
toString
()
==
'1'
&&
map
[
'riskLevel'
].
toString
().
isNotEmpty
)
{
rlevel
=
'Risk of COVID19 is avarage'
;
}
if
(
map
[
'riskLevel'
].
toString
()
==
'2'
&&
map
[
'riskLevel'
].
toString
().
isNotEmpty
)
{
rlevel
=
'Risk of COVID19 is high'
;
}
if
(
map
[
'riskLevel'
].
toString
()
!=
""
)
{
switch
(
map
[
'district'
])
{
case
'ampara'
:
print
(
"=========== Switch :"
+
map
[
'riskLevel'
].
toString
());
setState
(()
{
// mapKey = UniqueKey();
ampareRL
=
map
[
'riskLevel'
].
toString
();
});
break
;
case
'anuradhapura'
:
setState
(()
{
// mapKey = UniqueKey();
anuradhapuraRL
=
map
[
'riskLevel'
];
});
break
;
case
'badulla'
:
setState
(()
{
// mapKey = UniqueKey();
badullaRL
=
map
[
'riskLevel'
];
});
break
;
case
'batticaloa'
:
setState
(()
{
// mapKey = UniqueKey();
batticaloaRL
=
map
[
'riskLevel'
].
toString
();
});
break
;
case
'colombo'
:
setState
(()
{
// mapKey = UniqueKey();
colomboRL
=
map
[
'riskLevel'
];
});
break
;
case
'galle'
:
setState
(()
{
// mapKey = UniqueKey();
galleRL
=
map
[
'riskLevel'
];
});
break
;
case
'gampaha'
:
setState
(()
{
//mapKey = UniqueKey();
gampahaRL
=
map
[
'riskLevel'
].
toString
();
});
break
;
case
'hambantota'
:
setState
(()
{
// mapKey = UniqueKey();
hambantotaRL
=
map
[
'riskLevel'
];
});
break
;
case
'jaffna'
:
setState
(()
{
// mapKey = UniqueKey();
jaffnaRL
=
map
[
'riskLevel'
];
});
break
;
case
'kalmunai'
:
setState
(()
{
// mapKey = UniqueKey();
kalmunaiRL
=
map
[
'riskLevel'
].
toString
();
});
break
;
case
'kalutara'
:
setState
(()
{
// mapKey = UniqueKey();
kalutaraRL
=
map
[
'riskLevel'
];
});
break
;
case
'kandy'
:
setState
(()
{
// mapKey = UniqueKey();
kandyRL
=
map
[
'riskLevel'
];
});
break
;
case
'kegalle'
:
setState
(()
{
// mapKey = UniqueKey();
kegalleRL
=
map
[
'riskLevel'
].
toString
();
});
break
;
case
'kilinochchi'
:
setState
(()
{
// mapKey = UniqueKey();
kilinochchiRL
=
map
[
'riskLevel'
];
});
break
;
case
'kurunagala'
:
setState
(()
{
// mapKey = UniqueKey();
kurunagalaRL
=
map
[
'riskLevel'
];
});
break
;
case
'mannar'
:
setState
(()
{
// mapKey = UniqueKey();
mannarRL
=
map
[
'riskLevel'
].
toString
();
});
break
;
case
'matale'
:
setState
(()
{
// mapKey = UniqueKey();
mataleRL
=
map
[
'riskLevel'
];
});
break
;
case
'matara'
:
setState
(()
{
// mapKey = UniqueKey();
mataraRL
=
map
[
'riskLevel'
];
});
break
;
case
'monaragala'
:
setState
(()
{
// mapKey = UniqueKey();
monaragalaRL
=
map
[
'riskLevel'
].
toString
();
});
break
;
case
'mullaitivu'
:
setState
(()
{
// mapKey = UniqueKey();
mullaitivuRL
=
map
[
'riskLevel'
];
});
break
;
case
'nuwaraEliya'
:
setState
(()
{
// mapKey = UniqueKey();
nuwaraEliyaRL
=
map
[
'riskLevel'
];
});
break
;
case
'polonnaruwa'
:
setState
(()
{
// mapKey = UniqueKey();
polonnaruwaRL
=
map
[
'riskLevel'
].
toString
();
});
break
;
case
'puttalam'
:
setState
(()
{
// mapKey = UniqueKey();
puttalamRL
=
map
[
'riskLevel'
];
});
break
;
case
'ratnapura'
:
setState
(()
{
// mapKey = UniqueKey();
ratnapuraRL
=
map
[
'riskLevel'
];
});
break
;
case
'trincomalee'
:
setState
(()
{
// mapKey = UniqueKey();
trincomaleeRL
=
map
[
'riskLevel'
].
toString
();
});
break
;
case
'vavuniya'
:
setState
(()
{
// mapKey = UniqueKey();
vavuniyaRL
=
map
[
'riskLevel'
];
});
break
;
}
}
//print(map["date"]);
return
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
children:
<
Widget
>[
Container
(
child:
Icon
(
FontAwesomeIcons
.
heartbeat
,
color:
Colors
.
red
,
size:
15.0
,
),
),
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
8.0
),
child:
Container
(
child:
Text
(
districtName
,
style:
TextStyle
(
color:
Color
(
0xff6200ee
),
fontSize:
24.0
,
fontWeight:
FontWeight
.
bold
),
)),
),
SizedBox
(
height:
5.0
),
Container
(
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
children:
<
Widget
>[
Container
(
child:
Text
(
"Date : "
+
map
[
'date'
].
toString
()
==
""
?
" "
:
map
[
'date'
].
toString
(),
style:
TextStyle
(
color:
Colors
.
black54
,
fontSize:
18.0
,
),
)),
],
)),
SizedBox
(
height:
5.0
),
Container
(
child:
Text
(
"Cases during week
\
u00B7
\
u00B7 "
+
map
[
'cases'
].
toString
()
==
""
?
" "
:
"Reported cases during week : "
+
map
[
'cases'
].
toString
(),
style:
TextStyle
(
color:
Colors
.
black54
,
fontSize:
18.0
,
),
)),
SizedBox
(
height:
5.0
),
Container
(
child:
Text
(
rlevel
+
"
\
u00B7 Stay safe"
,
style:
TextStyle
(
color:
Colors
.
black54
,
fontSize:
18.0
,
fontWeight:
FontWeight
.
bold
),
)),
],
);
}
Widget
_buildGoogleMap
(
BuildContext
context
)
{
return
Container
(
// key: mapKey,
height:
MediaQuery
.
of
(
context
).
size
.
height
,
width:
MediaQuery
.
of
(
context
).
size
.
width
,
child:
GoogleMap
(
mapType:
MapType
.
normal
,
initialCameraPosition:
CameraPosition
(
target:
LatLng
(
7.8731
,
80.7718
),
zoom:
7
),
onMapCreated:
(
GoogleMapController
controller
)
{
_controller
.
complete
(
controller
);
},
///////////////
/////////////////
markers:
{
ampara
(
ampareRL
),
anuradhapura
(
anuradhapuraRL
),
badulla
(
badullaRL
),
batticaloa
(
batticaloaRL
),
colombo
(
colomboRL
),
galle
(
galleRL
),
gampaha
(
gampahaRL
),
hambantota
(
hambantotaRL
),
jaffna
(
jaffnaRL
),
kalmunai
(
kalmunaiRL
),
kalutara
(
kalutaraRL
),
kandy
(
kandyRL
),
kegalle
(
kegalleRL
),
kilinochchi
(
kilinochchiRL
),
kurunagala
(
kurunagalaRL
),
mannar
(
mannarRL
),
matale
(
mataleRL
),
matara
(
mataraRL
),
monaragala
(
monaragalaRL
),
mullaitivu
(
mullaitivuRL
),
nuwaraEliya
(
nuwaraEliyaRL
),
polonnaruwa
(
polonnaruwaRL
),
puttalam
(
puttalamRL
),
ratnapura
(
ratnapuraRL
),
trincomalee
(
trincomaleeRL
),
vavuniya
(
vavuniyaRL
),
},
),
);
}
Future
<
void
>
_gotoLocation
(
double
lat
,
double
long
)
async
{
final
GoogleMapController
controller
=
await
_controller
.
future
;
controller
.
animateCamera
(
CameraUpdate
.
newCameraPosition
(
CameraPosition
(
target:
LatLng
(
lat
,
long
),
zoom:
10
,
tilt:
50.0
,
bearing:
45.0
,
)));
}
////////////////
///////////////
Marker
ampara
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'ampara'
),
position:
LatLng
(
7.3018
,
81.6747
),
infoWindow:
InfoWindow
(
title:
'ampara'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
anuradhapura
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'anuradhapura'
),
position:
LatLng
(
8.3114
,
80.4037
),
infoWindow:
InfoWindow
(
title:
'anuradhapura'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
badulla
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'badulla'
),
position:
LatLng
(
6.9934
,
81.0550
),
infoWindow:
InfoWindow
(
title:
'badulla'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
batticaloa
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'batticaloa'
),
position:
LatLng
(
7.7310
,
81.6747
),
infoWindow:
InfoWindow
(
title:
'batticaloa'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
colombo
(
String
level
)
{
print
(
"========= Function : "
+
level
);
return
Marker
(
markerId:
MarkerId
(
'colombo'
),
position:
LatLng
(
6.9271
,
79.8612
),
infoWindow:
InfoWindow
(
title:
'colombo'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
galle
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'galle'
),
position:
LatLng
(
6.0535
,
80.2210
),
infoWindow:
InfoWindow
(
title:
'galle'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
gampaha
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'gampaha'
),
position:
LatLng
(
7.0840
,
80.0098
),
infoWindow:
InfoWindow
(
title:
'gampaha'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
hambantota
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'hambantota'
),
position:
LatLng
(
6.1429
,
81.1212
),
infoWindow:
InfoWindow
(
title:
'hambantota'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
jaffna
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'jaffna'
),
position:
LatLng
(
9.6615
,
80.0255
),
infoWindow:
InfoWindow
(
title:
'jaffna'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
kalmunai
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'kalmunai'
),
position:
LatLng
(
7.4144
,
81.8306
),
infoWindow:
InfoWindow
(
title:
'kalmunai'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
kalutara
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'kalutara'
),
position:
LatLng
(
6.5854
,
79.9607
),
infoWindow:
InfoWindow
(
title:
'kalutara'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
kandy
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'kandy'
),
position:
LatLng
(
7.2906
,
80.6337
),
infoWindow:
InfoWindow
(
title:
'kandy'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
kegalle
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'kegalle'
),
position:
LatLng
(
7.2513
,
80.3464
),
infoWindow:
InfoWindow
(
title:
'kegalle'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
kilinochchi
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'kilinochchi'
),
position:
LatLng
(
9.3803
,
80.3770
),
infoWindow:
InfoWindow
(
title:
'kilinochchi'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
kurunagala
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'kurunagala'
),
position:
LatLng
(
7.4818
,
80.3609
),
infoWindow:
InfoWindow
(
title:
'kurunagala'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
mannar
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'mannar'
),
position:
LatLng
(
8.9810
,
79.9044
),
infoWindow:
InfoWindow
(
title:
'mannar'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
matale
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'matale'
),
position:
LatLng
(
7.4675
,
80.6234
),
infoWindow:
InfoWindow
(
title:
'matale'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
matara
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'matara'
),
position:
LatLng
(
5.9549
,
80.5550
),
infoWindow:
InfoWindow
(
title:
'Matara'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
monaragala
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'monaragala'
),
position:
LatLng
(
6.8728
,
81.3507
),
infoWindow:
InfoWindow
(
title:
'monaragala'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
mullaitivu
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'mullaitivu'
),
position:
LatLng
(
9.2671
,
80.8142
),
infoWindow:
InfoWindow
(
title:
'mullaitivu'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
nuwaraEliya
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'nuwaraEliya'
),
position:
LatLng
(
6.9497
,
80.7891
),
infoWindow:
InfoWindow
(
title:
'nuwaraEliya'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
polonnaruwa
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'polonnaruwa'
),
position:
LatLng
(
7.9403
,
81.0188
),
infoWindow:
InfoWindow
(
title:
'polonnaruwa'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
puttalam
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'puttalam'
),
position:
LatLng
(
8.0408
,
79.8394
),
infoWindow:
InfoWindow
(
title:
'puttalam'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
ratnapura
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'ratnapura'
),
position:
LatLng
(
6.7056
,
80.3847
),
infoWindow:
InfoWindow
(
title:
'ratnapura'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
trincomalee
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'trincomalee'
),
position:
LatLng
(
8.5874
,
81.2152
),
infoWindow:
InfoWindow
(
title:
'trincomalee'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
Marker
vavuniya
(
String
level
)
{
return
Marker
(
markerId:
MarkerId
(
'vavuniya'
),
position:
LatLng
(
8.7542
,
80.4982
),
infoWindow:
InfoWindow
(
title:
'vavuniya'
),
icon:
BitmapDescriptor
.
defaultMarkerWithHue
(
// BitmapDescriptor.hueRed,
(
level
==
"0"
)
?
BitmapDescriptor
.
hueGreen
:
(
level
==
"1"
)
?
BitmapDescriptor
.
hueOrange
:
BitmapDescriptor
.
hueRed
),
);
}
}
lib/SRouter/dialogbox.dart
0 → 100644
View file @
f2944e44
import
'package:flutter/material.dart'
;
class
CustomDialog
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
return
Dialog
(
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
16.0
)),
elevation:
0.0
,
backgroundColor:
Colors
.
white
,
child:
dialogContent
(
context
),
);
}
Widget
dialogContent
(
BuildContext
context
)
{
return
Container
(
margin:
EdgeInsets
.
only
(
left:
0.0
,
right:
0.0
),
child:
Stack
(
children:
<
Widget
>[
Container
(
margin:
EdgeInsets
.
only
(
top:
13.0
,
right:
8.0
),
decoration:
BoxDecoration
(
color:
Colors
.
white
,
shape:
BoxShape
.
rectangle
,
borderRadius:
BorderRadius
.
circular
(
16.0
),
boxShadow:
<
BoxShadow
>[]),
child:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
crossAxisAlignment:
CrossAxisAlignment
.
stretch
,
children:
<
Widget
>[
SizedBox
(
height:
10.0
,
),
Center
(
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
10.0
),
child:
new
Text
(
"Sorry please try
\n
again tomorrow"
,
style:
TextStyle
(
fontSize:
10.0
,
color:
Colors
.
black
)),
)
//
),
SizedBox
(
height:
14.0
),
],
),
),
Positioned
(
right:
0.0
,
child:
GestureDetector
(
onTap:
()
{
Navigator
.
of
(
context
).
pop
();
},
child:
Align
(
alignment:
Alignment
.
topRight
,
child:
CircleAvatar
(
radius:
14.0
,
backgroundColor:
Colors
.
white
,
child:
Icon
(
Icons
.
close
,
color:
Colors
.
red
),
),
),
),
),
],
),
);
}
}
lib/SRouter/safeRoute.dart
0 → 100644
View file @
f2944e44
import
'dart:ui'
;
import
'package:covidefender/SRouter/srouterDashboard.dart'
;
import
'package:covidefender/SRouter/widgets/alertDialogBox.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:covidefender/SRouter/secrectMapKey.dart'
;
// Stores the Google Maps API Key
import
'package:flutter_polyline_points/flutter_polyline_points.dart'
;
import
'package:geocoding/geocoding.dart'
;
import
'package:geolocator/geolocator.dart'
;
import
'package:google_maps_flutter/google_maps_flutter.dart'
;
import
"dart:convert"
;
import
'package:cloud_firestore/cloud_firestore.dart'
;
import
'package:font_awesome_flutter/font_awesome_flutter.dart'
;
import
'dart:math'
show
cos
,
sqrt
,
asin
;
import
'package:quiver/iterables.dart'
;
class
MapView
extends
StatefulWidget
{
@override
_MapViewState
createState
()
=>
_MapViewState
();
}
class
_MapViewState
extends
State
<
MapView
>
{
var
districtDetails
=
[];
var
docs
=
[];
Future
_data
;
var
routine
=
[];
var
routeRiskLevel
;
var
uniqueRoutine
;
bool
isItemFound
=
false
;
final
FirebaseFirestore
firestore
=
FirebaseFirestore
.
instance
;
Future
_readData
()
async
{
//DocumentReference documentReference = Firestore.instance.collection("RiskLocation").document('');
DocumentSnapshot
documentSnapshot
;
try
{
/* documentSnapshot = await firestore
.collection('RiskLevel')
.document('Gampaha_2021-06-30')
.get();*/
documentSnapshot
=
// ignore: missing_return
await
firestore
.
collection
(
"RiskLevel"
)
.
orderBy
(
"date"
,
descending:
true
)
.
get
()
// ignore: missing_return
.
then
((
querySnapshot
)
{
querySnapshot
.
docs
.
forEach
((
result
)
{
// print(result.data());
setState
(()
{
districtDetails
.
add
(
result
.
data
());
});
// print(querySnapshot.docs);
// print(querySnapshot.docs[0].data().values.elementAt(3));
});
//print(districtDetails);
print
(
'ddddddddddddddddddddddddddddddddddddddddddddddddddddddd'
);
// print(riskList);
// return documentSnapshot;
});
/* print('documentSnapshot.data.toString()');
print(documentSnapshot.data.toString());
print(documentSnapshot.get('cases'));
print(documentSnapshot.data()['riskLevel']);*/
// print(documentSnapshot);
}
catch
(
e
)
{
print
(
e
);
}
}
CameraPosition
_initialLocation
=
CameraPosition
(
target:
LatLng
(
7.8731
,
80.7718
),
zoom:
7
);
GoogleMapController
mapController
;
Position
_currentPosition
;
String
_currentAddress
=
''
;
final
startAddressController
=
TextEditingController
();
final
destinationAddressController
=
TextEditingController
();
final
startAddressFocusNode
=
FocusNode
();
final
desrinationAddressFocusNode
=
FocusNode
();
String
_startAddress
=
''
;
String
_destinationAddress
=
''
;
String
_placeDistance
;
Set
<
Marker
>
markers
=
{};
PolylinePoints
polylinePoints
;
Map
<
PolylineId
,
Polyline
>
polylines
=
{};
List
<
LatLng
>
polylineCoordinates
=
[];
final
_scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
Widget
_textField
({
TextEditingController
controller
,
FocusNode
focusNode
,
String
label
,
String
hint
,
double
width
,
Icon
prefixIcon
,
Widget
suffixIcon
,
Function
(
String
)
locationCallback
,
})
{
return
Container
(
width:
width
*
0.8
,
child:
TextField
(
style:
TextStyle
(
color:
Colors
.
white
),
onChanged:
(
value
)
{
locationCallback
(
value
);
},
controller:
controller
,
focusNode:
focusNode
,
decoration:
new
InputDecoration
(
prefixIcon:
prefixIcon
,
suffixIcon:
suffixIcon
,
labelText:
label
,
labelStyle:
TextStyle
(
color:
Colors
.
white70
),
filled:
true
,
fillColor:
Colors
.
white30
,
enabledBorder:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
10.0
),
),
borderSide:
BorderSide
(
color:
Colors
.
white
,
width:
2
,
),
),
focusedBorder:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
10.0
),
),
borderSide:
BorderSide
(
color:
Colors
.
white
,
width:
2
,
),
),
contentPadding:
EdgeInsets
.
all
(
15
),
hintText:
hint
,
hintStyle:
TextStyle
(
color:
Colors
.
white54
)),
),
);
}
// Method for retrieving the current location
_getCurrentLocation
()
async
{
print
(
'999999999999999999999999999999999999999999999999999999999999999999999999999'
);
await
Geolocator
.
getCurrentPosition
(
desiredAccuracy:
LocationAccuracy
.
high
)
.
then
((
Position
position
)
async
{
setState
(()
{
_currentPosition
=
position
;
print
(
'999999999999999999999999999999999999999999999999999999999999999999999999999'
);
print
(
'CURRENT POS:
$_currentPosition
'
);
mapController
.
animateCamera
(
CameraUpdate
.
newCameraPosition
(
CameraPosition
(
target:
LatLng
(
position
.
latitude
,
position
.
longitude
),
zoom:
14.0
,
),
),
);
});
await
_getAddress
();
}).
catchError
((
e
)
{
print
(
e
);
});
}
// Method for retrieving the address
_getAddress
()
async
{
try
{
List
<
Placemark
>
p
=
await
placemarkFromCoordinates
(
_currentPosition
.
latitude
,
_currentPosition
.
longitude
);
Placemark
place
=
p
[
0
];
setState
(()
{
_currentAddress
=
"
${place.name}
,
${place.locality}
,
${place.postalCode}
,
${place.country}
"
;
startAddressController
.
text
=
_currentAddress
;
_startAddress
=
_currentAddress
;
});
}
catch
(
e
)
{
print
(
e
);
}
}
// Method for calculating the distance between two places
Future
<
bool
>
_calculateDistance
()
async
{
try
{
// Retrieving placemarks from addresses
List
<
Location
>
startPlacemark
=
await
locationFromAddress
(
_startAddress
);
List
<
Location
>
destinationPlacemark
=
await
locationFromAddress
(
_destinationAddress
);
// Use the retrieved coordinates of the current position,
// instead of the address if the start position is user's
// current position, as it results in better accuracy.
double
startLatitude
=
_startAddress
==
_currentAddress
?
_currentPosition
.
latitude
:
startPlacemark
[
0
].
latitude
;
double
startLongitude
=
_startAddress
==
_currentAddress
?
_currentPosition
.
longitude
:
startPlacemark
[
0
].
longitude
;
double
destinationLatitude
=
destinationPlacemark
[
0
].
latitude
;
double
destinationLongitude
=
destinationPlacemark
[
0
].
longitude
;
String
startCoordinatesString
=
'(
$startLatitude
,
$startLongitude
)'
;
String
destinationCoordinatesString
=
'(
$destinationLatitude
,
$destinationLongitude
)'
;
// Start Location Marker
Marker
startMarker
=
Marker
(
markerId:
MarkerId
(
startCoordinatesString
),
position:
LatLng
(
startLatitude
,
startLongitude
),
infoWindow:
InfoWindow
(
title:
'Start
$startCoordinatesString
'
,
snippet:
_startAddress
,
),
icon:
BitmapDescriptor
.
defaultMarker
,
);
// Destination Location Marker
Marker
destinationMarker
=
Marker
(
markerId:
MarkerId
(
destinationCoordinatesString
),
position:
LatLng
(
destinationLatitude
,
destinationLongitude
),
infoWindow:
InfoWindow
(
title:
'Destination
$destinationCoordinatesString
'
,
snippet:
_destinationAddress
,
),
icon:
BitmapDescriptor
.
defaultMarker
,
);
// Adding the markers to the list
markers
.
add
(
startMarker
);
markers
.
add
(
destinationMarker
);
print
(
'START COORDINATES: (
$startLatitude
,
$startLongitude
)'
,
);
print
(
'DESTINATION COORDINATES: (
$destinationLatitude
,
$destinationLongitude
)'
,
);
// Calculating to check that the position relative
// to the frame, and pan & zoom the camera accordingly.
double
miny
=
(
startLatitude
<=
destinationLatitude
)
?
startLatitude
:
destinationLatitude
;
double
minx
=
(
startLongitude
<=
destinationLongitude
)
?
startLongitude
:
destinationLongitude
;
double
maxy
=
(
startLatitude
<=
destinationLatitude
)
?
destinationLatitude
:
startLatitude
;
double
maxx
=
(
startLongitude
<=
destinationLongitude
)
?
destinationLongitude
:
startLongitude
;
double
southWestLatitude
=
miny
;
double
southWestLongitude
=
minx
;
double
northEastLatitude
=
maxy
;
double
northEastLongitude
=
maxx
;
// Accommodate the two locations within the
// camera view of the map
mapController
.
animateCamera
(
CameraUpdate
.
newLatLngBounds
(
LatLngBounds
(
northeast:
LatLng
(
northEastLatitude
,
northEastLongitude
),
southwest:
LatLng
(
southWestLatitude
,
southWestLongitude
),
),
40.0
,
),
);
// Calculating the distance between the start and the end positions
// with a straight path, without considering any route
// double distanceInMeters = await Geolocator.bearingBetween(
// startLatitude,
// startLongitude,
// destinationLatitude,
// destinationLongitude,
// );
await
_createPolylines
(
startLatitude
,
startLongitude
,
destinationLatitude
,
destinationLongitude
);
double
totalDistance
=
0.0
;
// Calculating the total distance by adding the distance
// between small segments
for
(
int
i
=
0
;
i
<
polylineCoordinates
.
length
-
1
;
i
++)
{
totalDistance
+=
_coordinateDistance
(
polylineCoordinates
[
i
].
latitude
,
polylineCoordinates
[
i
].
longitude
,
polylineCoordinates
[
i
+
1
].
latitude
,
polylineCoordinates
[
i
+
1
].
longitude
,
);
}
setState
(()
{
_placeDistance
=
totalDistance
.
toStringAsFixed
(
2
);
print
(
'DISTANCE:
$_placeDistance
km'
);
});
return
true
;
}
catch
(
e
)
{
print
(
e
);
}
return
false
;
}
// Formula for calculating distance between two coordinates
// https://stackoverflow.com/a/54138876/11910277
double
_coordinateDistance
(
lat1
,
lon1
,
lat2
,
lon2
)
{
var
p
=
0.017453292519943295
;
var
c
=
cos
;
var
a
=
0.5
-
c
((
lat2
-
lat1
)
*
p
)
/
2
+
c
(
lat1
*
p
)
*
c
(
lat2
*
p
)
*
(
1
-
c
((
lon2
-
lon1
)
*
p
))
/
2
;
return
12742
*
asin
(
sqrt
(
a
));
}
// Create the polylines for showing the route between two places
_createPolylines
(
double
startLatitude
,
double
startLongitude
,
double
destinationLatitude
,
double
destinationLongitude
,
)
async
{
print
(
'77777777777777777777777777777777777777777777777777777777777'
);
print
(
districtDetails
[
21
][
'cases'
]);
print
(
'ddddddddddddddddddddddddddddddvggggggggggggggggggggggggggggggggggggg'
);
var
objList
=
[
{
'date'
:
districtDetails
[
0
][
'date'
],
'district'
:
districtDetails
[
0
][
'district'
],
'riskLevel'
:
int
.
parse
(
districtDetails
[
0
][
'riskLevel'
]),
'cases'
:
int
.
parse
(
districtDetails
[
0
][
'cases'
])
},
{
'district'
:
districtDetails
[
1
][
'district'
],
'date'
:
districtDetails
[
1
][
'date'
],
'riskLevel'
:
int
.
parse
(
districtDetails
[
1
][
'riskLevel'
]),
'cases'
:
int
.
parse
(
districtDetails
[
1
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
2
][
'riskLevel'
]),
'district'
:
districtDetails
[
2
][
'district'
],
'date'
:
districtDetails
[
2
][
'date'
],
'cases'
:
int
.
parse
(
districtDetails
[
2
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
3
][
'riskLevel'
]),
'district'
:
districtDetails
[
3
][
'district'
],
'date'
:
districtDetails
[
3
][
'date'
],
'cases'
:
int
.
parse
(
districtDetails
[
3
][
'cases'
])
},
{
'date'
:
districtDetails
[
4
][
'date'
],
'riskLevel'
:
int
.
parse
(
districtDetails
[
4
][
'riskLevel'
]),
'district'
:
districtDetails
[
4
][
'district'
],
'cases'
:
int
.
parse
(
districtDetails
[
4
][
'cases'
])
},
{
'district'
:
districtDetails
[
5
][
'district'
],
'date'
:
districtDetails
[
5
][
'date'
],
'riskLevel'
:
int
.
parse
(
districtDetails
[
5
][
'riskLevel'
]),
'cases'
:
int
.
parse
(
districtDetails
[
5
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
6
][
'riskLevel'
]),
'date'
:
districtDetails
[
6
][
'date'
],
'district'
:
districtDetails
[
6
][
'district'
],
'cases'
:
int
.
parse
(
districtDetails
[
6
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
7
][
'riskLevel'
]),
'date'
:
districtDetails
[
7
][
'date'
],
'district'
:
districtDetails
[
7
][
'district'
],
'cases'
:
int
.
parse
(
districtDetails
[
7
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
8
][
'riskLevel'
]),
'date'
:
districtDetails
[
8
][
'date'
],
'district'
:
districtDetails
[
8
][
'district'
],
'cases'
:
int
.
parse
(
districtDetails
[
8
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
9
][
'riskLevel'
]),
'date'
:
districtDetails
[
9
][
'date'
],
'district'
:
districtDetails
[
9
][
'district'
],
'cases'
:
int
.
parse
(
districtDetails
[
9
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
10
][
'riskLevel'
]),
'date'
:
districtDetails
[
10
][
'date'
],
'district'
:
districtDetails
[
10
][
'district'
],
'cases'
:
int
.
parse
(
districtDetails
[
10
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
11
][
'riskLevel'
]),
'date'
:
districtDetails
[
11
][
'date'
],
'district'
:
districtDetails
[
11
][
'district'
],
'cases'
:
int
.
parse
(
districtDetails
[
11
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
12
][
'riskLevel'
]),
'date'
:
districtDetails
[
12
][
'date'
],
'district'
:
districtDetails
[
12
][
'district'
],
'cases'
:
int
.
parse
(
districtDetails
[
12
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
13
][
'riskLevel'
]),
'date'
:
districtDetails
[
13
][
'date'
],
'district'
:
districtDetails
[
13
][
'district'
],
'cases'
:
int
.
parse
(
districtDetails
[
13
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
14
][
'riskLevel'
]),
'date'
:
districtDetails
[
14
][
'date'
],
'district'
:
districtDetails
[
14
][
'district'
],
'cases'
:
int
.
parse
(
districtDetails
[
14
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
15
][
'riskLevel'
]),
'district'
:
districtDetails
[
15
][
'district'
],
'date'
:
districtDetails
[
15
][
'date'
],
'cases'
:
int
.
parse
(
districtDetails
[
15
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
16
][
'riskLevel'
]),
'district'
:
districtDetails
[
16
][
'district'
],
'date'
:
districtDetails
[
16
][
'date'
],
'cases'
:
int
.
parse
(
districtDetails
[
16
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
17
][
'riskLevel'
]),
'district'
:
districtDetails
[
17
][
'district'
],
'date'
:
districtDetails
[
17
][
'date'
],
'cases'
:
int
.
parse
(
districtDetails
[
17
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
18
][
'riskLevel'
]),
'district'
:
districtDetails
[
18
][
'district'
],
'date'
:
districtDetails
[
18
][
'date'
],
'cases'
:
int
.
parse
(
districtDetails
[
18
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
19
][
'riskLevel'
]),
'district'
:
districtDetails
[
19
][
'district'
],
'date'
:
districtDetails
[
19
][
'date'
],
'cases'
:
int
.
parse
(
districtDetails
[
19
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
20
][
'riskLevel'
]),
'district'
:
districtDetails
[
20
][
'district'
],
'date'
:
districtDetails
[
20
][
'date'
],
'cases'
:
int
.
parse
(
districtDetails
[
20
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
21
][
'riskLevel'
]),
'district'
:
districtDetails
[
21
][
'district'
],
'date'
:
districtDetails
[
21
][
'date'
],
'cases'
:
int
.
parse
(
districtDetails
[
21
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
22
][
'riskLevel'
]),
'district'
:
districtDetails
[
22
][
'district'
],
'date'
:
districtDetails
[
22
][
'date'
],
'cases'
:
int
.
parse
(
districtDetails
[
22
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
23
][
'riskLevel'
]),
'district'
:
districtDetails
[
23
][
'district'
],
'date'
:
districtDetails
[
23
][
'date'
],
'cases'
:
int
.
parse
(
districtDetails
[
23
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
24
][
'riskLevel'
]),
'district'
:
districtDetails
[
24
][
'district'
],
'date'
:
districtDetails
[
24
][
'date'
],
'cases'
:
int
.
parse
(
districtDetails
[
24
][
'cases'
])
},
{
'riskLevel'
:
int
.
parse
(
districtDetails
[
25
][
'riskLevel'
]),
'district'
:
districtDetails
[
25
][
'district'
],
'date'
:
districtDetails
[
25
][
'date'
],
'cases'
:
int
.
parse
(
districtDetails
[
25
][
'cases'
])
}
];
var
cordinatesLst
=
[
{
'district'
:
'vavuniya'
,
'lat'
:
8.7
,
'long'
:
80.4
},
{
'district'
:
'trincomalee'
,
'lat'
:
8.5
,
'long'
:
81.2
},
{
'lat'
:
6.7
,
'district'
:
'ratnapura'
,
'long'
:
80.3
},
{
'lat'
:
8.0
,
'district'
:
'puttalam'
,
'long'
:
79.8
},
{
'lat'
:
7.9
,
'district'
:
'polonnaruwa'
,
'long'
:
81.0
},
{
'district'
:
'nuwara eliya'
,
'lat'
:
6.9
,
'long'
:
80.7
},
{
'lat'
:
9.2
,
'district'
:
'mullaitivu'
,
'long'
:
80.8
},
{
'district'
:
'monaragala'
,
'lat'
:
6.87
,
'long'
:
81.35
},
{
'lat'
:
5.9
,
'district'
:
'matara'
,
'long'
:
80.5
},
{
'lat'
:
7.4
,
'district'
:
'matale'
,
'long'
:
80.6
},
{
'lat'
:
8.9
,
'district'
:
'mannar'
,
'long'
:
79.9
},
{
'lat'
:
7.4
,
'district'
:
'kurunagala'
,
'long'
:
80.3
},
{
'district'
:
'kilinochchi'
,
'lat'
:
9.3
,
'long'
:
80.3
},
{
'district'
:
'kegalle'
,
'lat'
:
7.2
,
'long'
:
80.3
},
{
'district'
:
'kandy'
,
'lat'
:
7.2
,
'long'
:
80.6
},
{
'lat'
:
6.5
,
'district'
:
'kalutara'
,
'long'
:
79.9
},
{
'lat'
:
7.4
,
'district'
:
'kalmunai'
,
'long'
:
81.8
},
{
'lat'
:
9.6
,
'district'
:
'jaffna'
,
'long'
:
80.0
},
{
'district'
:
'hambantota'
,
'lat'
:
6.1
,
'long'
:
81.1
},
{
'lat'
:
7.0
,
'district'
:
'gampaha'
,
'long'
:
80.0
},
{
'lat'
:
6.0
,
'district'
:
'galle'
,
'long'
:
80.2
},
{
'district'
:
'colombo'
,
'lat'
:
6.9
,
'long'
:
79.9
},
{
'lat'
:
7.7
,
'district'
:
'batticaloa'
,
'long'
:
81.6
},
{
'district'
:
'badulla'
,
'lat'
:
6.9
,
'long'
:
81.0
},
{
'district'
:
'anuradhapura'
,
'lat'
:
8.3
,
'long'
:
80.4
},
{
'district'
:
'ampara'
,
'lat'
:
7.3
,
'long'
:
81.6
}
];
final
districtRisks
=
cordinatesLst
.
map
((
item
)
{
final
risk
=
objList
.
where
((
values
)
=>
values
[
"district"
]
==
item
[
"district"
])
.
map
((
rl
)
=>
rl
[
"riskLevel"
]
as
int
)
.
first
;
return
item
..[
"riskLevel"
]
=
risk
;
});
print
(
'arr3_______________________________________________________________'
);
//print(districtRisks);
print
(
'arr3_______________________________________________________________'
);
polylinePoints
=
PolylinePoints
();
PolylineResult
result
=
await
polylinePoints
.
getRouteBetweenCoordinates
(
SecrectMapKey
.
API_KEY
,
// Google Maps API Key
PointLatLng
(
startLatitude
,
startLongitude
),
PointLatLng
(
destinationLatitude
,
destinationLongitude
),
// travelMode: TravelMode.transit,
);
print
(
result
.
points
);
// print(result.points.first);
print
(
'ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss'
);
print
(
result
.
points
.
last
);
var
arr
=
[];
double
getNumber
(
double
input
,
{
int
precision
=
2
})
=>
double
.
parse
(
'
$input
'
.
substring
(
0
,
'
$input
'
.
indexOf
(
'.'
)
+
precision
+
1
));
result
.
points
.
forEach
((
element
)
{
arr
.
add
({
'lat'
:
getNumber
(
element
.
latitude
,
precision:
1
),
'long'
:
getNumber
(
element
.
longitude
,
precision:
1
)
});
});
print
(
arr
);
bool
isNearlyEqual
(
var
actual
,
var
calculated
)
{
return
(
actual
-
calculated
).
abs
()
<
0.1
;
}
final
jsonList
=
arr
.
map
((
item
)
=>
jsonEncode
(
item
)).
toList
();
final
uniqueJsonList
=
jsonList
.
toSet
().
toList
();
final
results
=
uniqueJsonList
.
map
((
item
)
=>
jsonDecode
(
item
)).
toList
();
//print(results);
print
(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
);
var
a
=
[];
districtRisks
.
forEach
((
element
)
=>
{
results
.
forEach
((
e
)
=>
{
if
((
element
[
'lat'
]
==
e
[
'lat'
])
&&
isNearlyEqual
(
element
[
'long'
],
e
[
'long'
]))
// if ((element['lat'] == e['lat']) &&
// (element['long'] == e['long']))
{
//element.values.elementAt(3).toString(),
a
.
add
(
element
.
values
.
elementAt
(
3
)),
print
(
element
),
routine
.
add
(
element
)
}
})
});
uniqueRoutine
=
routine
.
toSet
().
toList
();
/* uniqueRoutine = routine.map((e) => e.id).toSet();
routine.retainWhere((x) => routine.remove(x.id));*/
print
(
'eeeeeeeeeeeeeeeeeeeEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEeee'
);
print
(
uniqueRoutine
);
print
(
'eeeeeeeeeeeeeeeeeeeEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEeee'
);
//print(a);
print
(
a
.
reduce
((
curr
,
next
)
=>
curr
>
next
?
curr
:
next
));
routeRiskLevel
=
a
.
reduce
((
curr
,
next
)
=>
curr
>
next
?
curr
:
next
);
num
sum
=
0
;
a
.
forEach
((
e
)
{
sum
+=
e
;
});
//routeRiskLevel = sum / a.length;
print
(
sum
/
a
.
length
);
if
(
result
.
points
.
isNotEmpty
)
{
result
.
points
.
forEach
((
PointLatLng
point
)
{
polylineCoordinates
.
add
(
LatLng
(
point
.
latitude
,
point
.
longitude
));
});
}
PolylineId
id
=
PolylineId
(
'poly'
);
Polyline
polyline
=
Polyline
(
polylineId:
id
,
//color: Colors.red,
color:
(
routeRiskLevel
==
0
)
?
Colors
.
green
:
(
routeRiskLevel
==
1
)
?
Colors
.
orangeAccent
:
Colors
.
red
,
points:
polylineCoordinates
,
width:
3
,
);
polylines
[
id
]
=
polyline
;
}
@override
void
initState
()
{
super
.
initState
();
_data
=
_readData
();
// _getCurrentLocation();
}
@override
Widget
build
(
BuildContext
context
)
{
_deleteItem
(
var
item
)
{
routine
.
remove
(
item
);
setState
(()
{});
}
var
height
=
MediaQuery
.
of
(
context
).
size
.
height
;
var
width
=
MediaQuery
.
of
(
context
).
size
.
width
;
_showMaterialDialog
()
{
print
(
'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT'
);
print
(
routine
[
0
][
'riskLevel'
]);
showDialog
(
context:
context
,
builder:
(
_
)
=>
new
AlertDialog
(
title:
Container
(
height:
70
,
child:
Column
(
children:
[
(
routeRiskLevel
==
0
)
?
new
Text
(
'This route has a low risk'
,
style:
TextStyle
(
fontSize:
15.0
,
color:
Colors
.
green
))
:
(
routeRiskLevel
==
1
)
?
new
Text
(
'This route has a average risk'
,
style:
TextStyle
(
fontSize:
15.0
,
color:
Colors
.
orange
))
:
new
Text
(
'This route has a high risk'
,
style:
TextStyle
(
fontSize:
15.0
,
color:
Colors
.
red
)),
new
Text
(
'Distance :'
+
' '
+
_placeDistance
+
' '
+
'km'
,
style:
TextStyle
(
fontSize:
11.0
,
color:
Colors
.
blueAccent
.
shade700
,
)),
(
routeRiskLevel
==
2
)
?
new
Text
(
'High Risk Area... '
,
style:
TextStyle
(
fontSize:
14.0
,
color:
Colors
.
red
))
:
new
Text
(
'No high risk area....'
,
style:
TextStyle
(
fontSize:
14.0
,
color:
Colors
.
green
)),
Container
(
height:
17
,
child:
ListView
.
builder
(
scrollDirection:
Axis
.
horizontal
,
padding:
const
EdgeInsets
.
all
(
0
),
itemCount:
uniqueRoutine
.
length
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
Container
(
// height: 10,
padding:
const
EdgeInsets
.
all
(
0.0
),
// // color: Colors.amber[colorCodes[index]],
child:
Center
(
child:
(
uniqueRoutine
[
index
][
'riskLevel'
]
==
2
)
?
Text
(
uniqueRoutine
[
index
][
'district'
]
+
' '
+
' '
,
style:
TextStyle
(
fontSize:
14.0
,
color:
Colors
.
red
.
shade900
))
:
Container
(),
));
}),
),
],
),
),
));
}
return
Container
(
height:
height
,
width:
width
,
child:
Scaffold
(
appBar:
AppBar
(
backwardsCompatibility:
false
,
backgroundColor:
Colors
.
blueAccent
.
shade700
,
title:
Text
(
"Find Route"
),
),
key:
_scaffoldKey
,
body:
Stack
(
children:
<
Widget
>[
// Map View
GoogleMap
(
markers:
Set
<
Marker
>.
from
(
markers
),
initialCameraPosition:
_initialLocation
,
myLocationEnabled:
true
,
myLocationButtonEnabled:
false
,
mapType:
MapType
.
normal
,
zoomGesturesEnabled:
true
,
zoomControlsEnabled:
false
,
polylines:
Set
<
Polyline
>.
of
(
polylines
.
values
),
onMapCreated:
(
GoogleMapController
controller
)
{
mapController
=
controller
;
},
),
// Show zoom buttons
SafeArea
(
child:
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
10.0
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
ClipOval
(
child:
Material
(
color:
Colors
.
white
,
// button color
child:
InkWell
(
splashColor:
Colors
.
blue
,
// inkwell color
child:
SizedBox
(
width:
40
,
height:
40
,
child:
Icon
(
Icons
.
add
),
),
onTap:
()
{
// _showMaterialDialog();
mapController
.
animateCamera
(
CameraUpdate
.
zoomIn
(),
);
},
),
),
),
SizedBox
(
height:
20
),
ClipOval
(
child:
Material
(
color:
Colors
.
white
,
// button color
child:
InkWell
(
splashColor:
Colors
.
blue
,
// inkwell color
child:
SizedBox
(
width:
40
,
height:
40
,
child:
Icon
(
Icons
.
remove
),
),
onTap:
()
{
mapController
.
animateCamera
(
CameraUpdate
.
zoomOut
(),
);
},
),
),
)
],
),
),
),
// Show the place input fields & button for
// showing the route
SafeArea
(
child:
Align
(
alignment:
Alignment
.
bottomCenter
,
child:
Padding
(
padding:
const
EdgeInsets
.
only
(
top:
4.6
),
child:
Container
(
decoration:
BoxDecoration
(
color:
Colors
.
black45
,
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
20.0
),
),
),
width:
width
*
0.8
,
// height: height * 0.4,
child:
Padding
(
padding:
const
EdgeInsets
.
only
(
top:
5.0
,
bottom:
8.0
),
child:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
children:
<
Widget
>[
Text
(
'Locations'
,
style:
TextStyle
(
fontSize:
18.0
,
color:
Colors
.
white
),
),
SizedBox
(
height:
1
),
_textField
(
label:
'Start'
,
hint:
'Choose starting point'
,
// Added this
prefixIcon:
Icon
(
Icons
.
looks_one
,
color:
Colors
.
white70
),
suffixIcon:
IconButton
(
icon:
Icon
(
Icons
.
my_location
,
color:
Colors
.
white
,
),
onPressed:
()
{
_getCurrentLocation
();
startAddressController
.
text
=
_currentAddress
;
_startAddress
=
_currentAddress
;
},
),
controller:
startAddressController
,
focusNode:
startAddressFocusNode
,
width:
300
,
locationCallback:
(
String
value
)
{
setState
(()
{
_startAddress
=
value
;
});
}),
SizedBox
(
height:
10
),
_textField
(
label:
'Destination'
,
hint:
'Choose destination'
,
prefixIcon:
Icon
(
Icons
.
looks_two
,
color:
Colors
.
white70
),
controller:
destinationAddressController
,
focusNode:
desrinationAddressFocusNode
,
width:
300
,
locationCallback:
(
String
value
)
{
setState
(()
{
_destinationAddress
=
value
;
});
}),
SizedBox
(
height:
2
),
// Visibility(
// visible: _placeDistance == null ? false : true,
/* child: Text(
'DISTANCE: $_placeDistance km',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),*/
// ),
SizedBox
(
height:
2
),
ElevatedButton
(
onPressed:
(
_startAddress
!=
''
&&
_destinationAddress
!=
''
)
?
()
async
{
startAddressFocusNode
.
unfocus
();
desrinationAddressFocusNode
.
unfocus
();
setState
(()
{
if
(
markers
.
isNotEmpty
)
markers
.
clear
();
if
(
polylines
.
isNotEmpty
)
polylines
.
clear
();
if
(
polylineCoordinates
.
isNotEmpty
)
polylineCoordinates
.
clear
();
_placeDistance
=
null
;
});
routine
=
[];
_calculateDistance
().
then
((
isCalculated
)
{
/* if (isCalculated) {
ScaffoldMessenger.of(context)
.showSnackBar(
SnackBar(
content: Text(
'Distance Calculated Sucessfully'),
),
);
} else {
ScaffoldMessenger.of(context)
.showSnackBar(
SnackBar(
content: Text(
'Error Calculating Distance'),
),
);
}*/
_showMaterialDialog
();
});
// _showMaterialDialog();
}
:
null
,
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
Text
(
'Show Route'
.
toUpperCase
(),
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
13.0
,
),
),
),
style:
ElevatedButton
.
styleFrom
(
primary:
Colors
.
red
,
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
20.0
),
),
),
),
],
),
),
),
),
),
),
// Show current location button
SafeArea
(
child:
Align
(
alignment:
Alignment
.
bottomRight
,
child:
Padding
(
padding:
const
EdgeInsets
.
only
(
right:
10.0
,
bottom:
10.0
),
child:
ClipOval
(
child:
Material
(
color:
Colors
.
orange
.
shade100
,
// button color
child:
InkWell
(
splashColor:
Colors
.
orange
,
// inkwell color
child:
SizedBox
(
width:
56
,
height:
56
,
child:
Icon
(
Icons
.
my_location
),
),
onTap:
()
{
_getCurrentLocation
();
mapController
.
animateCamera
(
CameraUpdate
.
newCameraPosition
(
CameraPosition
(
target:
LatLng
(
_currentPosition
.
latitude
,
_currentPosition
.
longitude
,
),
zoom:
18.0
,
),
),
);
},
),
),
),
),
),
),
],
),
),
);
}
}
lib/SRouter/secrectMapKey.dart
0 → 100644
View file @
f2944e44
class
SecrectMapKey
{
// Add your Google Maps API Key here
static
const
API_KEY
=
'AIzaSyBuDih9ioyQAR9ikg3zEoE_5mhXvZh5oAw'
;
}
lib/SRouter/srouterDashboard.dart
0 → 100644
View file @
f2944e44
import
'package:flutter/material.dart'
;
import
'MapDesignPage.dart'
;
import
'safeRoute.dart'
;
import
'dialogbox.dart'
;
class
SrouterDashboard
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
backwardsCompatibility:
false
,
backgroundColor:
Colors
.
blueAccent
.
shade700
,
title:
Text
(
"SRouter Map"
),
),
body:
Stack
(
children:
<
Widget
>[
Container
(
decoration:
BoxDecoration
(
image:
DecorationImage
(
alignment:
Alignment
.
topCenter
,
image:
NetworkImage
(
'https://assets.materialup.com/uploads/0ecf34f4-3948-4c5b-912d-fbd2bbe7372a/preview.gif'
),
))),
SafeArea
(
child:
Padding
(
padding:
EdgeInsets
.
all
(
16.0
),
child:
Column
(
children:
<
Widget
>[
SizedBox
(
height:
40
,
),
Container
(
height:
64
,
margin:
EdgeInsets
.
only
(
bottom:
20
),
child:
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
CircleAvatar
(
radius:
32
,
backgroundColor:
Colors
.
transparent
,
backgroundImage:
NetworkImage
(
'https://www.countdown2030europe.org/storage/app/media/uploaded-files/rotating-globe-slow.gif'
),
),
SizedBox
(
width:
15
,
),
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
Text
(
'Safe Route Map'
,
style:
TextStyle
(
fontSize:
32.0
,
color:
Colors
.
deepPurpleAccent
.
shade700
),
)
],
)
],
),
),
SizedBox
(
height:
22
,
),
Expanded
(
child:
GridView
.
count
(
mainAxisSpacing:
10
,
crossAxisSpacing:
10
,
primary:
false
,
crossAxisCount:
2
,
padding:
const
EdgeInsets
.
all
(
8.0
),
children:
<
Widget
>[
Card
(
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
8
)),
elevation:
4
,
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
FlatButton
(
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
MapDesignPage
()),
);
},
child:
Container
(
height:
85.0
,
width:
110.0
,
decoration:
BoxDecoration
(
image:
DecorationImage
(
image:
NetworkImage
(
'https://c8.alamy.com/comp/P1A2B4/abstract-city-map-background-with-marker-P1A2B4.jpg'
),
fit:
BoxFit
.
cover
,
),
),
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
),
),
),
SizedBox
(
height:
4
,
),
Text
(
'COVID 19 Map'
,
style:
TextStyle
(
fontSize:
18
,
color:
Colors
.
deepPurpleAccent
.
shade700
),
),
],
)),
Card
(
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
8
)),
elevation:
4
,
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
FlatButton
(
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
MapView
()),
);
},
child:
Container
(
width:
110.0
,
height:
95.0
,
decoration:
BoxDecoration
(
image:
DecorationImage
(
image:
NetworkImage
(
'https://st3.depositphotos.com/1021974/12545/i/600/depositphotos_125458496-stock-photo-map-with-pin-in-route.jpg'
,
),
),
),
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
),
),
),
SizedBox
(
height:
0
,
),
Text
(
'Find Route'
,
style:
TextStyle
(
fontSize:
18
,
color:
Colors
.
deepPurpleAccent
.
shade700
),
),
],
)),
Card
(
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
8
)),
elevation:
4
,
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
FlatButton
(
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
CustomDialog
()),
);
},
child:
Container
(
width:
110.0
,
height:
80.0
,
decoration:
BoxDecoration
(
image:
DecorationImage
(
image:
NetworkImage
(
'https://media.istockphoto.com/photos/blurred-dining-table-restaurant-with-beautiful-city-view-at-twilight-picture-id1169370670?k=6&m=1169370670&s=612x612&w=0&h=I8ZJFy28mH5o6HuNJ6AyoequAK1-pq-77rgnOtg3eHY='
),
fit:
BoxFit
.
cover
,
),
),
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
),
),
),
SizedBox
(
height:
4
,
),
Text
(
'City Details'
,
style:
TextStyle
(
fontSize:
18
,
color:
Colors
.
deepPurpleAccent
.
shade700
),
),
],
)),
Card
(
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
8
)),
elevation:
4
,
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
FlatButton
(
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
MapDesignPage
()),
);
},
child:
Container
(
height:
80.0
,
width:
110.0
,
decoration:
BoxDecoration
(
image:
DecorationImage
(
image:
NetworkImage
(
'https://media.istockphoto.com/photos/stethoscope-on-blue-background-picture-id866772230'
),
fit:
BoxFit
.
cover
,
),
),
),
),
SizedBox
(
height:
4
,
),
Text
(
'Other Details'
,
style:
TextStyle
(
fontSize:
18
,
color:
Colors
.
deepPurpleAccent
.
shade700
),
),
],
)),
],
),
)
],
),
),
)
],
),
);
}
}
lib/SRouter/widgets/alertDialogBox.dart
0 → 100644
View file @
f2944e44
import
'package:flutter/material.dart'
;
class
AlertBox
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
margin:
EdgeInsets
.
only
(
left:
0.0
,
right:
0.0
),
child:
Stack
(
children:
<
Widget
>[
Container
(
margin:
EdgeInsets
.
only
(
top:
13.0
,
right:
8.0
),
decoration:
BoxDecoration
(
color:
Colors
.
white
,
shape:
BoxShape
.
rectangle
,
borderRadius:
BorderRadius
.
circular
(
16.0
),
boxShadow:
<
BoxShadow
>[]),
child:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
crossAxisAlignment:
CrossAxisAlignment
.
stretch
,
children:
<
Widget
>[
SizedBox
(
height:
10.0
,
),
Center
(
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
10.0
),
child:
new
Text
(
"Sorry please try
\n
again tomorrow"
,
style:
TextStyle
(
fontSize:
10.0
,
color:
Colors
.
black
)),
)
//
),
SizedBox
(
height:
14.0
),
],
),
),
Positioned
(
right:
0.0
,
child:
GestureDetector
(
onTap:
()
{
Navigator
.
of
(
context
).
pop
();
},
child:
Align
(
alignment:
Alignment
.
topRight
,
child:
CircleAvatar
(
radius:
14.0
,
backgroundColor:
Colors
.
white
,
child:
Icon
(
Icons
.
close
,
color:
Colors
.
red
),
),
),
),
),
],
),
);
}
}
lib/home_screen.dart
View file @
f2944e44
import
'package:covidefender/I_GUIDER/splashIguider.dart'
;
import
'package:covidefender/SRouter/srouterDashboard.dart'
;
import
'package:covidefender/STracker/splash.dart'
;
import
'package:covidefender/EAnalyzer/Loading.dart'
;
import
'package:flutter/material.dart'
;
...
...
@@ -95,13 +96,18 @@ class _HomeScreenState extends State<HomeScreen> {
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
Container
(
height:
size
.
height
*
.
1
,
decoration:
BoxDecoration
(
image:
DecorationImage
(
image:
AssetImage
(
'lib/assets/images/map80.png'
)),
)),
FlatButton
(
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
SrouterDashboard
()),
);
},
child:
Image
.
asset
(
'lib/assets/images/map80.png'
),
),
Text
(
'Map'
,
style:
TextStyle
(
fontSize:
20.0
))
],
)),
...
...
pubspec.lock
View file @
f2944e44
...
...
@@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.
5.0
"
version: "2.
6.1
"
boolean_selector:
dependency: transitive
description:
...
...
@@ -141,6 +141,20 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
name: flutter_plugin_android_lifecycle
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
flutter_polyline_points:
dependency: "direct main"
description:
name: flutter_polyline_points
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.4"
flutter_spinkit:
dependency: "direct main"
description:
...
...
@@ -165,6 +179,62 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
font_awesome_flutter:
dependency: "direct main"
description:
name: font_awesome_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "9.1.0"
geocoding:
dependency: "direct main"
description:
name: geocoding
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
geocoding_platform_interface:
dependency: transitive
description:
name: geocoding_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1+1"
geolocator:
dependency: "direct main"
description:
name: geolocator
url: "https://pub.dartlang.org"
source: hosted
version: "6.2.1"
geolocator_platform_interface:
dependency: transitive
description:
name: geolocator_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.9"
geolocator_web:
dependency: transitive
description:
name: geolocator_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
google_maps_flutter:
dependency: "direct main"
description:
name: google_maps_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.6"
google_maps_flutter_platform_interface:
dependency: transitive
description:
name: google_maps_flutter_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
http:
dependency: "direct main"
description:
...
...
@@ -338,6 +408,48 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
url_launcher:
dependency: transitive
description:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "5.7.10"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+4"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+9"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.9"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.5+3"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+3"
vector_math:
dependency: transitive
description:
...
...
pubspec.yaml
View file @
f2944e44
...
...
@@ -51,6 +51,11 @@ dependencies:
git
:
url
:
http://github.com/indikaNK/plugins.git
path
:
packages/camera/camera
google_maps_flutter
:
^2.0.6
font_awesome_flutter
:
^9.1.0
flutter_polyline_points
:
^0.2.4
geocoding
:
^1.0.5
geolocator
:
^6.2.1
dev_dependencies
:
...
...
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