Skip to content

Commit 637d58c

Browse files
Apk Buil Version 1.0.0
1 parent 322892c commit 637d58c

5 files changed

Lines changed: 47 additions & 72 deletions

File tree

ResponseApp/lib/main.dart

Lines changed: 28 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import 'dart:io';
2-
import 'dart:async';
32
import 'package:flutter/material.dart';
43
import 'package:flutter/services.dart';
5-
import 'package:google_maps_flutter/google_maps_flutter.dart';
64

7-
// import 'views/DetailedNewsPage.dart';
8-
// import 'views/HomePage.dart';
9-
// import 'views/MapsBody.dart';
10-
// import 'views/NewsBody.dart';
11-
// import 'views/OnboardingScreen.dart';
12-
// import 'views/SOS.dart';
13-
// import 'views/SOSselect.dart';
14-
// import 'views/WhatToDoBody.dart';
15-
// import 'package:response/views/Flood.dart';
5+
import 'views/DetailedNewsPage.dart';
6+
import 'views/HomePage.dart';
7+
import 'views/MapsBody.dart';
8+
import 'views/NewsBody.dart';
9+
import 'views/OnboardingScreen.dart';
10+
import 'views/SOS.dart';
11+
import 'views/SOSselect.dart';
12+
import 'views/WhatToDoBody.dart';
13+
import 'package:response/views/Flood.dart';
1614

1715
void main() {
1816
SystemChrome.setSystemUIOverlayStyle(
@@ -32,55 +30,29 @@ void main() {
3230
runApp(ResponseApp());
3331
}
3432

35-
class ResponseApp extends StatefulWidget {
36-
@override
37-
_ResponseAppState createState() => _ResponseAppState();
38-
}
39-
40-
class _ResponseAppState extends State<ResponseApp> {
41-
Completer<GoogleMapController> _controller = Completer();
42-
43-
static const LatLng _center = const LatLng(45.521563, -122.677433);
44-
45-
void _onMapCreated(GoogleMapController controller) {
46-
_controller.complete(controller);
47-
}
48-
33+
class ResponseApp extends StatelessWidget {
4934
@override
5035
Widget build(BuildContext context) {
5136
return MaterialApp(
5237
debugShowCheckedModeBanner: false,
53-
// initialRoute: HomePage.id,
54-
// routes: {
55-
// OnboardingScreen.id: (context) => OnboardingScreen(),
56-
//
57-
// //Home Screens
58-
// HomePage.id: (context) => HomePage(),
59-
// WhatToDoBody.id: (context) => WhatToDoBody(),
60-
// NewsBody.id: (context) => NewsBody(),
61-
// MapsBody.id: (context) => MapsBody(),
62-
// Flood.id: (context) => Flood(),
63-
//
64-
// //SOS page
65-
// SOS.id: (context) => SOS(),
66-
// SOSselect.id: (context) => SOSselect(),
67-
//
68-
// //Detailed Screens
69-
// DetailedNewsPage.id: (context) => DetailedNewsPage(),
70-
// },
71-
home: Scaffold(
72-
appBar: AppBar(
73-
title: Text('Maps Sample App'),
74-
backgroundColor: Colors.green[700],
75-
),
76-
body: GoogleMap(
77-
onMapCreated: _onMapCreated,
78-
initialCameraPosition: CameraPosition(
79-
target: _center,
80-
zoom: 11.0,
81-
),
82-
),
83-
),
38+
initialRoute: HomePage.id,
39+
routes: {
40+
OnboardingScreen.id: (context) => OnboardingScreen(),
41+
42+
//Home Screens
43+
HomePage.id: (context) => HomePage(),
44+
WhatToDoBody.id: (context) => WhatToDoBody(),
45+
NewsBody.id: (context) => NewsBody(),
46+
MapsBody.id: (context) => MapsBody(),
47+
Flood.id: (context) => Flood(),
48+
49+
//SOS page
50+
SOS.id: (context) => SOS(),
51+
SOSselect.id: (context) => SOSselect(),
52+
53+
//Detailed Screens
54+
DetailedNewsPage.id: (context) => DetailedNewsPage(),
55+
},
8456
);
8557
}
8658
}

ResponseApp/lib/utilities/LocationService.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
import 'package:geolocator/geolocator.dart';
22
import 'package:geocoder/geocoder.dart';
3+
import 'dart:async';
34

45
class LocationService {
56
String _userLocation = 'INDIA';
67
double latitude;
78
double longitude;
89

910
Future<String> getLocation() async {
11+
GeolocationStatus geolocationStatus =
12+
await Geolocator().checkGeolocationPermissionStatus();
13+
1014
try {
1115
Position position = await Geolocator()
12-
.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium);
16+
.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
17+
18+
// Position position = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.medium);
1319

1420
final coordinates = Coordinates(position.latitude, position.longitude);
1521
var addresses =
@@ -46,8 +52,10 @@ class LocationService {
4652
Position position = await Geolocator()
4753
.getCurrentPosition(desiredAccuracy: LocationAccuracy.low);
4854

55+
print("here ${position.latitude}");
4956
return position.latitude;
5057
} catch (e) {
58+
print(e);
5159
return 20.5937;
5260
}
5361
}

ResponseApp/lib/views/MapsBody.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class _MapsBodyState extends State<MapsBody> {
5555
markerId: MarkerId(_lastMapPosition.toString()),
5656
position: _lastMapPosition,
5757
infoWindow: InfoWindow(
58-
title: 'Really cool place',
59-
snippet: '5 Star Rating',
58+
title: 'Your Current Location',
59+
snippet: "Mumbai",
6060
),
6161
icon: BitmapDescriptor.defaultMarker,
6262
));
@@ -73,11 +73,8 @@ class _MapsBodyState extends State<MapsBody> {
7373

7474
@override
7575
void initState() {
76-
// getLocationData();
77-
76+
getLocationData();
7877
super.initState();
79-
80-
//map code
8178
}
8279

8380
@override

ResponseApp/lib/views/NewsBody.dart

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class _NewsBodyState extends State<NewsBody> {
2121
String _isClicked = 'national';
2222

2323
LocationService locationService = LocationService();
24-
var userLocation;
24+
var userLocation = "MUMBAI";
2525

2626
//New firestore instance
2727
final _firestore = Firestore.instance;
@@ -31,13 +31,15 @@ class _NewsBodyState extends State<NewsBody> {
3131

3232
@override
3333
void initState() {
34-
super.initState();
3534
getLocationData();
35+
super.initState();
3636
}
3737

38-
void getLocationData() async {
38+
//Needs to be future!
39+
Future getLocationData() async {
3940
// Fetching _userLocation
4041
userLocation = await locationService.getLocation();
42+
setState(() {});
4143
}
4244

4345
@override
@@ -49,8 +51,6 @@ class _NewsBodyState extends State<NewsBody> {
4951
allowFontScaling: true,
5052
);
5153

52-
print(userLocation);
53-
5454
return Column(
5555
children: [
5656
CustomAppBar(),
@@ -167,10 +167,7 @@ class _NewsBodyState extends State<NewsBody> {
167167
: news.data['location']);
168168

169169
String newsLocation = location.toUpperCase();
170-
171-
//TODO: userLocation giving null
172-
var temp = "MUMBAI";
173-
if (temp.contains(newsLocation)) {
170+
if (userLocation.contains(newsLocation)) {
174171
//date conversion
175172
DateTime myDateTime =
176173
DateTime.parse(news.data['date'].toDate().toString());

ResponseApp/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ dependencies:
2929
intl:
3030
geolocator: ^5.3.2+2
3131
geocoder: ^0.2.1
32+
# permission_handler: ^5.0.1+1
3233

3334
# Google Services:
3435
provider: ^4.3.1

0 commit comments

Comments
 (0)