Professional Documents
Culture Documents
in
Submitted by
NAME USN
GUIDE
CERTIFICATE
This is to certify that the students Chidambar Inamdar, Deepak N Kumble, Gourav
Shanbhag, Irfan Kamate of 7th semester bearing USN’s 2GI19CS035, 2GI19CS038,
2GI19CS046, 2GI19CS052 have satisfactorily completed the course activity (Project) in
Mobile Application Development course (Course code: 18CSL78). It can be considered as
a bonafide work carried out in partial fulfillment for the academic requirement of 7th
Semester B.E prescribed by KLS Gogte Institute of Technology, Belagavi during the
academic year 2022- 2023.
The report has been approved as it satisfies the academic requirements in respect of
Assignment (Course project) prescribed for the said Degree.
Date: 02-01-2023
1|Page
Marks allocation
Batch No.:
Total 20
2|Page
TRACK MY FRIEND APP
PROBLEM STATEMENT
There might be a time when someone wants to get the location of their friends. The
result could be losing a chance to hang out and catch up with colleague or missing out
on meeting someone dear that they will probably never be able to see again. Either
way, it is unfortunate not being able to have a mobile service that can prevent such
circumstances when most mobile phones are equipped with a Geographical
Positioning System (GPS) and tools to define and manage users' connections.
Thus, develop an app to show your friends location.
INTRODUCTION
Mobile phones have become a major part of our daily lives. The importance of them is since
they are an easy way of communication, Internet access and social media. They also save
money, ensure safety, help in business and many more.
Mobile phones can support a wide range of applications, giving them many of the same
functions available on a laptop but without the extra bulk.
Anyone who has a smart phone or another mobile device probably uses apps to play games,
get directions, access news, books, weather, and so on. Mobile apps are easy to download, are
often free and are convenient such that sometimes users might download them without
thinking about some key considerations: how they are paid for, what information they may
gather from the device, or who gets that information.
There is a need to continue to develop new apps that serve the growing demands of mobile
users. The market of mobile apps makes use of new mobile and hardware technologies, and
therefor expands with the expansion of these technologies.
During the past few decades, advancements in technology have been exceptionally fast,
especially in computer and mobile technologies. This fast improvement resulted in a need to
develop applications and services that enhance human lives.
Global Positioning System (GPS) is the technique that is used to determine the position of
objects on the Earth surface. This technique has become widely used in many desktop and
mobile applications.
3|Page
FUNCTIONAL BLOCK DIAGRAM
4|Page
WORKING MODEL
Login Page:
Contents:
5|Page
Location Update:
Friend’s Location:
6|Page
WORKING CODE
Login:
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:friendtracker/LoginPage.dart';
import 'package:friendtracker/mainPage.dart';
Future main() async{
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MaterialApp(home:Signin()));
}
class Signin extends StatefulWidget {
const Signin({Key? key}) : super(key: key);
@override
State<Signin> createState() => _SigninState();
}
class _SigninState extends State<Signin> {
final controllername = new TextEditingController();
final controllerphoneno = new TextEditingController();
double deviceHeight(BuildContext context) => MediaQuery.of(context).size.height;
double deviceWidth(BuildContext context) => MediaQuery.of(context).size.width;
final _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Friend Locator'),
centerTitle: true,
),
body: Form(
key: _formKey,
child: Center(
child: Column(
children: [
SizedBox(height: 40,),
Text('Signin Page',style: TextStyle(
fontSize: 30,
),),
SizedBox(
height: 30,
),
7|Page
SizedBox(
child: TextFormField(
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter some text';
}
return null;
},
controller: controllerphoneno,
decoration: InputDecoration(
labelText: 'Phone Number',
border: OutlineInputBorder(),
),
style: TextStyle(
fontSize: 20,
),
),
width: 350,
),
SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(child: ElevatedButton(onPressed: () async{
final phoneno = controllerphoneno.text;
bool exist = false;
if (_formKey.currentState!.validate()) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Processing Data')),
);
try{
await
FirebaseFirestore.instance.doc("Coordinates/$phoneno").get().then((doc){
exist = doc.exists;
});
}
catch(e){
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Firebase document check failed')),
);
}
8|Page
if(exist == true){
Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder:
(context)=>Home(userid: phoneno,)),(context)=>false);
}
else{
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('User id Not found, Try once again')),
);
}
}
},
child: Text('Signin',style: TextStyle(
fontSize: 20,
),)
),
width: 150,
),
SizedBox(child: ElevatedButton(onPressed: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>Login()));
},
child: Text('Signup',style: TextStyle(
fontSize: 20,
),)
),
width: 130,
),
],
)
],
),
);
}
}
SignIn page:
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:friendtracker/mainPage.dart';
Future main() async{
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MaterialApp(home:Login()));
9|Page
}
class Login extends StatefulWidget {
const Login({Key? key}) : super(key: key);
@override
State<Login> createState() => _LoginState();
}
class _LoginState extends State<Login> {
final controllername = new TextEditingController();
final controllerphoneno = new TextEditingController();
Future createUser({required String name,required String phoneNo}) async{
final docUser = FirebaseFirestore.instance.collection('Coordinates').doc(phoneNo);
final user = User(
name: name,
lat: '0.0',
long: '0.0',
phno: phoneNo,
);
final json = user.toJson();
await docUser.set(json);
}
double deviceHeight(BuildContext context) => MediaQuery.of(context).size.height;
double deviceWidth(BuildContext context) => MediaQuery.of(context).size.width;
final _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Friend Locator'),
centerTitle: true,
),
body: Form(
key: _formKey,
child: Center(
child: Column(
children: [
SizedBox(height: 40,),
Text('Signup Page',style: TextStyle(
fontSize: 30,
),),
SizedBox(
height: 30,
),
SizedBox(
child: TextFormField(
10 | P a g e
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter some text';
}
return null;
},
controller: controllername,
decoration: InputDecoration(
labelText: 'Name',
border: OutlineInputBorder(),
),
style: TextStyle(
fontSize: 20,
),
),
width: 350,
),
SizedBox(
height: 20,
),
SizedBox(
child: TextFormField(
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter some text';
}
return null;
},
controller: controllerphoneno,
decoration: InputDecoration(
labelText: 'Phone Number',
border: OutlineInputBorder(),
),
style: TextStyle(
fontSize: 20,
),
),
width: 350,
),
SizedBox(
height: 20,
),
SizedBox(child: ElevatedButton(onPressed: (){
if (_formKey.currentState!.validate()) {
11 | P a g e
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Processing Data')),
);
final name = controllername.text;
final phoneNo = controllerphoneno.text;
createUser(name: name, phoneNo: phoneNo);
Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder:
(context)=>Home(userid: phoneNo),), (route) => false);
}
},
child: Text('Login',style: TextStyle(
fontSize: 20,
),)
),
width: 150,
),
],
),
);
}
}
class User{
final String lat;
final String long;
final String name;
final String phno;
User({
required this.name,
required this.lat,
required this.long,
required this.phno,
});
Map<String ,dynamic> toJson() =>{
'name': name,
'lat' : lat,
'long' : long,
'phno' : phno,
};
}
12 | P a g e
import 'package:firebase_core/firebase_core.dart';
import 'package:geolocator/geolocator.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:friendtracker/friendList.dart';
Future main() async{
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MaterialApp(home:Home(userid: '')));
}
class Home extends StatefulWidget {
final String userid;
const Home({Key? key,required this.userid}) : super(key: key);
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
String locationMessage = 'Current Location of the User';
late String lat;
late String long;
Future<Position> _getCurrentLocation() async{
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
if(!serviceEnabled){
return Future.error('Location services are disabled');
}
LocationPermission permission = await Geolocator.checkPermission();
if(permission == LocationPermission.denied){
permission = await Geolocator.requestPermission();
if(permission == LocationPermission.denied){
return Future.error('Location permission are denied');
}
}
if(permission == LocationPermission.deniedForever){
return Future.error('Location Permission are permanently denied, we cannot request the
location');
}
return Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.high
);
}
void _liveLocation(){
LocationSettings locationSettings = const LocationSettings(
accuracy: LocationAccuracy.high,
distanceFilter: 100,
);
13 | P a g e
Geolocator.getPositionStream(locationSettings: locationSettings).listen((Position position)
{
lat = position.latitude.toString();
long = position.longitude.toString();
});
}
Future<void> _openMap(String lat, String long) async{
String googleURL= 'https://www.google.com/maps/search/?api=1&query=$lat,$long';
await canLaunch(googleURL)
? await launch(googleURL)
: throw 'could not launch $googleURL';
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Friend Locator'),
centerTitle: true,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(locationMessage,textAlign: TextAlign.center,),
const SizedBox(height: 20,),
const SizedBox(height: 20,),
ElevatedButton(onPressed: (){
_getCurrentLocation().then((value) {
lat = '${value.latitude}';
long = '${value.longitude}';
final lat1 = lat;
final long1 = long;
final docUser =
FirebaseFirestore.instance.collection('Coordinates').doc(widget.userid);
docUser.update({
'lat' : lat1,
'long' : long1,
});
print(lat);
print(long);
_liveLocation();
});
}, child: const Text('Update my Current Location')),
const SizedBox(height:20),
14 | P a g e
ElevatedButton(onPressed: (){
_openMap(lat, long);
}, child: const Text('Show my location')),
SizedBox(height: 20,),
ElevatedButton(onPressed: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>friendList()));
}, child: Text('Friends List'))
],
)
);
}
}
class User{
final String lat;
final String long;
final String name;
final String phno;
User({
required this.name,
required this.lat,
required this.long,
required this.phno,
});
Map<String ,dynamic> toJson() =>{
'name': name,
'lat' : lat,
'long' : long,
'phno' : phno,
};
}
15 | P a g e
}
class friendList extends StatefulWidget {
const friendList({Key? key}) : super(key: key);
@override
State<friendList> createState() => _friendListState();
}
class _friendListState extends State<friendList> {
late String lat;
late String long;
Stream<List<User>> readUsers() => FirebaseFirestore.instance.collection('Coordinates')
.snapshots()
.map((snapshot) =>
snapshot.docs.map((doc)=> User.fromJson(doc.data())).toList());
Widget buildUser(User user)=> Material(
child: ListTile(
leading: CircleAvatar(child: Text('${user.name[0]}'),),
title: Text(user.name.toString(),style: TextStyle(
fontSize: 18,
),),
subtitle: Text(user.phno),
onTap: () async{
String googleURL= 'https://www.google.com/maps/search/?api=1&query=${user.lat},$
{user.long}';
await canLaunch(googleURL)
? await launch(googleURL)
: throw 'could not launch $googleURL';
},
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(0),
side: BorderSide(
color: Colors.black26,
)),
),
elevation: 2.0,
);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title:Text('Friend Locator'),
centerTitle: true,
),
body: StreamBuilder<List<User>>(
stream: readUsers(),
16 | P a g e
builder: (context,snapshot){
if(snapshot.hasData){
final users = snapshot.data!;
return ListView(
children: users.map(buildUser).toList(),
);
}
else if(snapshot.hasError){
return Text('Something went wrong! ${snapshot.error}');
}
else{
return Center(child: CircularProgressIndicator(),);
}
}
),
);
}
}
class User{
final String lat;
final String long;
final String name;
final String phno;
User({
required this.name,
required this.lat,
required this.long,
required this.phno,
});
Map<String ,dynamic> toJson() =>{
'name': name,
'lat' : lat,
'long' : long,
'phno' : phno,
};
static User fromJson(Map<String , dynamic> json) => User(
name: json['name'],
lat: json['lat'],
long: json['long'],
phno: json['phno'],
);
}
CONCLUSION
17 | P a g e
In this project, a mobile application has been developed, FriendTracker, which:
REFERENCES
https://spaceplace.nasa.gov/gps/en/
https://www8.garmin.com/aboutGPS/
https://en.wikipedia.org/wiki/Find_My_Friends
https://www.lucidchart.com
18 | P a g e