MMS 2 Project
MMS 2 Project
MMS 2 Project
SOCIAL MANAGEMENT
project on
“INSTAGRAM CLONE
APPLICATION ”
Submitted in partial fulfilment for the award of
the degree of
Master of Management Studies (MMS)
(under University of Mumbai)
Submitted By
STUDENT NAME: Nikhil Laxman Engole
(Roll No: M222411)
SPECIALIZATION
Under The Guidance of
DR/PROF - AVISHEK RAY
SOCIAL MANAGEMENT
project on
“INSTAGRAM CLONE
APPLICATION ”
Submitted in partial fulfilment for the award of
the degree of
Master of Management Studies (MMS)
(under University of Mumbai)
Submitted By
STUDENT NAME: Nikhil Laxman Engole
(Roll No: M222411)
SPECIALIZATION
Under The Guidance of
DR/PROF - AVISHEK RAY
ACKNOWLEDGEMENT
Through this acknowledgement I express my sincere gratitude
towards all those people who
helped me in this project, which has been a learning experience.
This space wouldn't be enough to extend my warm gratitude towards
my project guide RIYA RUPANI
for her efforts in coordinating with my work and guiding in right
direction.
I escalate a heartfelt regard to our Institution HOD for giving me the
essential hand in concluding
this work.
It would be injustice to proceed without acknowledging those vital
supports I received from my
beloved classmates and friends, without whom I would have been
half done.
I also use this space to offer my sincere love to my mother and sister
and all others who had
been there, helping me walk through this work.
Nikhil Laxman Engole
CERTIFICATE
This is to certify that project titled “A STUDY ON CSR OF AMUL”
successfully completed by Mr./Ms. Nikhil Laxman Engole
pursuing the IV Semester, in partial fulfilment of the Master's Degree
in Management Studies Recognized by the University of Mumbai for
the academic year 2023-24 through KC COLLEGE OF ENGINEERING
MANAGEMENT STUDIES KC COLLEGE ६ RESEARCH
This project work is original and not submitted earlier for the award
of any degree / diploma or associateship of any other University /
Institution.
Name: Nikhil Laxman Engole
Date: 1 may 2024
(Signature of the Guide)
DECLARATION
Hereby declare that this Project Report submitted by me to the
MMS DEPARTMENT is a Bonafide work undertaken by me and it is not
submitted to any other University or Institution for the award of any
degree diploma/ certificate or published any time before.
Name: Nikhil Laxman Engole
Roll No: M222411
(Signature of the student)
TABLE OF CONTENT
S.R no. Topic Name Page
1 Introduction
1.1 Background 8
1.2 Objective 9
1.3 Purpose, Scope, and Applicability 9
1.3.1 Purpose 10
1.3.2 Scope 10
1.3.3 Applicability 10
2 System Analysis
2.1 Existing System 11
2.2 Proposed System 11
2.3 Requirement Analysis 11
2.4 Hardware Requirement 12
2.5 Software Requirement 12
2.6 Justification of selection of Technology 12
3 System Design
3.1 Modul Division 13-16
3.2 Data Dictionary 16-21
3.3 ER Diagrams 22-23
3.4 DFD/UML Diagrams 24-27
4 Implementation
4.1 Code 27-55
4.2 Testing Approach 56
4.2.1 Unit Testing(Test cases and Test Results) 56-57
4.2.2 Integration System(Test cases and Test Result) 57
5 Result and Discussion 57-61
6 Conclusion and Future Work 61
7 Reference 61
Chapter 1
Introduction
Instagram Clone is the replica of the Instagram app, where users can
share images and video content and that can visible to the audience across the
globe. Instagram Clone is our pre-built social media app software that helps
entrepreneurs to build an Instagram like app. Our Instagram Clone script has
several unique features. Features ca be added, deleted, and modified easily in
the Instagram Clone Script. We provide a simple, easy & seamless user
experience. And our clone script is optimized to support numerous operations
in real-time, with minimal delay.
Instagram app provides various features like sharing photos, videos,
branding, influencing, snap shots, shopping and even many more things are
present but the vary common thing is gaming, which is going to be present in
the clone app. The Instagram Clone app will be running in multiple Operating
System like Android, Mac, Web. And Instagram Clone app is one of the best
ideas for establishing the business in which the customization will be done to
make it different from the exact one.
BACKGROUOND
Instagram is all about for fun and business platform where one can start their
start-up like selling cloth’s, cosmetic’s, jewellery’s, study materials, some share
their travel experience, food blogs, study blogs, some influencer motivate other
user and to achieve success in life. Talking about fun part of Instagram, User
upload their daily life event in Instagram Clone via sharing photos and videos
and snapshots. When Users are free or bored they watch memes and Reels to
relax themselves and to consume their time by that. But sometimes user get
bored by watching reels and memes, so the newest feature is gaming in
Instagram. Instagram gaming feature has many games which will build logic and
concentration of user. It will be fun to playing games in Instagram by sharing
their scores and competing with their friends or family member. Instagram also
provide messaging and video call to connect people from far away. It provide
may employability.
As Instagram help us to know what kind of interest person is having and
in which field a person can build their carrier. Instagram is a platform where a
person can have detail of anything from scratch, and get chance to connect
with people from anywhere in the world, and get the perfect guidance form
the person who is in the specific field.
Objective
The main purpose of Instagram clone is to share their creative ideas of
games. Now a days gaming has become the biggest part of human life because
gaming gave us platform to earn money by developing and playing game, it
provides huge championship or battlefield to many players and begun their
carrier.
In this Clone Application, we will get chance to challenge many players
with whom we are connected or and many champions from all over the world.
And we can our achievement through post it as a post or in our feeds. Which
will help others to learn how to play the game or challenge someone.
SCOPES:
The following use-cases are in scope:
1. Users should be able to upload their photos and videos.
2. Users should be able to like a post posted by other users.
3. Users should be able to follow other users.
4. Users should be able to view NewsFeed from other users they are
following.
Not in Scope
The following use-cases are out scope:
1. Push Notification to users for updates.
2. Users are able to search Post across the platform.
3. Photo Filters, Post Comments & Location-based tagging.
4. User stories automatically expiring at 24 hours.
5. User messaging to an individual user or a group.
• Dart platform
• Flutter engine
• Foundation library
• Design-specific widgets
• Flutter Development Tools (DevTools)
Dart Language
Flutter apps are written in the Dart language and make use of many of the
language's more advanced features.
While writing and debugging an application, Flutter runs in the Dart virtual
machine, which features a just-in-time execution engine. This allows for fast
compilation times as well as "hot reload", with which modifications to source
files can be injected into a running application. Flutter extends this further with
support for stateful hot reload, where in most cases changes to source code are
reflected immediately in the running app without requiring a restart or any loss
of state.
For better performance, release versions of Flutter apps on all platforms use
ahead-of-time (AOT) compilation,[19] except for on the Web where code is
transpiled to JavaScript.
Flutter inherits Dart's Pub package manager and software repository, which
allows users to publish and use custom packages as well as Flutter-specific
plugins.
Flutter engine
Flutter's engine, written primarily in C++, provides low-level rendering support
using either Google's Skia graphics library or the custom "Impeller" graphics
layer.[16] Additionally, it interfaces with platform-specific SDKs such as those
provided by Android and iOS to implement accessibility, file and network I/O,
native plugin support, and more.
Foundation library
The Foundation library, written in Dart, provides basic classes and functions
that are used to construct applications using Flutter, such as APIs to
communicate with the engine.
Design-specific widgets
The Flutter framework contains two sets of widgets that conform to specific
design languages: Material Design widgets implement Google's design
language of the same name, and Cupertino widgets implement Apple's iOS
Human interface guidelines
Firebase
Firebase is a set of hosting services for any type of application (Android,
iOS, Javascript, Node.js, Java, Unity, PHP, C++ ...). It offers NoSQL and
real-time hosting of databases, content, social authentication (Google,
Facebook, Twitter and Github), and notifications, or services, such as a
real-time communication server.
10
Preliminary
Investigation
System
Analysis
System
Design
System
Coding
11
System Testing
System
Implementation
12
Create Account:
The user can simply sign in using Facebook account or create a new account by
providing required personal information about himself/herself. After creating
the account it will display account crate successfully.
Searching Friend:
Search for those people whom the user wants to follow.
Sending Follow Request:
After finding the people the user can send him or her the follow request and
others can also send follow request to the user.
Accepting Follow Request:
After sending follow request if they accept the follow request and other able to
see, like, share, comment on their posts.
Uploading Photos, Videos:
To Upload any photo or video first select the respective file from the gallery if
someone wants to edit they can. After editing the can simply share the photo or
any other text posts.
Like, Comment, Share:
The users can like each others posts, they can write something in the comment
section, they can even share others posts.
b Non-Functional Requirement Security:
The system use SSL(secured socket layer) in all transactions that includes any
other confidential passenger information. The system should such secure that it
should not show any cookies regarding the password or the username of the
user so that no one rather than the user can access the system.
Reliability:
The system provides database for storage for all kinds of device whether it is a
computer or mobile or something else. The reliability of the whole system
depends on the reliable that it should not crash or hang during the use by the
user.
Maintainability:
13
There are many people those are there for the maintenance purpose of the
system. They can be software engineers or team of hackers. They are their to
take care of that if there is some problems regarding the system or not.
Portability:
The system consist of scripting languages such as PHP,HTML etc. It should run
on any device and any platform or in any operating system whether it is
windows, IOs or android.
14
15
Software:
1.Flutter
Studio Language:
Front-End Languages:
Server:
Conceptual Models:
Agile Model
16
Agile model believes that every project needs to be handled differently and the existing methods
need to be tailored to best suit the project requirements. In Agile, the tasks are divided to time
boxes (small time frames) to deliver specific features for a release.
Iterative approach is taken and working software build is delivered after each iteration. Each
build is incremental in terms of features; the final build holds all the features required by the
customer.
The Agile thought process had started early in the software development and started becoming
popular with time due to its flexibility and adaptability.
The most popular Agile methods include Rational Unified Process (1994), Scrum (1995),
Crystal Clear, Extreme Programming (1996), Adaptive Software Development, Feature Driven
Development, and Dynamic Systems Development Method (DSDM) (1995). These are now
collectively referred to as Agile Methodologies, after the Agile Manifesto was published in
2001. Following are the Agile Manifesto principles −
• Individuals and interactions − In Agile development, self-organization and
motivation are important, as are interactions like co-location and pair programming.
• Working software − Demo working software is considered the best means of
communication with the customers to understand their requirements, instead of just
depending on documentation.
17
Basic Modules:
There are various modules in this project we are going to add such as
• Sign-Up Page
• Login Page
• Home Page
• Profile Page
• Search Page
• Update Page
• Data Design:
18
user_id: (Integer) ID of the user who owns this photo (Indexed field)
19
Schema Design:
Table Photo:
20
or
DateTime)
Tabel Comment:
Field Datatype Key
comment_id: (Integer) Primary ID that
preferably auto
increments (if supported
in chosen DB)
comment: (Text) a simple text field
containing the comment
Tabel Photo_Comment:
Field Datatype Key
photo_id: (Integer) ID of the photo
comment_id: (Integer) ID of the comment being
assigned to a photo
Table: hashtags
Field Datatype Key
hashtag_id: (Integer) Primary ID that preferably
auto increments (if
supported in chosen DB)
hashtag: (Text) a simple text field
containing the hashtag
Table photos_hashtags
Field Datatype Key
photo_id: (Integer) ID of the photo
hashtag_id: (Integer) ID of the hashtag being
assigned to a photo
Table: likes
Field Datatype Key
user_id: (Integer) ID of the user performing
the like (Indexed field)
photo_id: (Integer) ID of the photo being
liked (Indexed field)
21
Table: tags
Field Datatype Key
id: (Integer) Primary ID that
preferably auto
increments (if
supported in chosen
DB)
name: (String) Tag name
Table: photos_tags
Field Data Type Key
photo_id: (Integer) ID of the photo being
tagged
tag_id: (Integer) ID of the tag being
assigned to a photo
Table: users
Field Data Type Key
user_id: (Integer) Primary ID that
preferably auto
increments (if supported
in chosen DB)
username: (String) Username (Unique
Index)
email: (String) Email address (Unique
Index)
salted_password: (String) Salted password digest
first_name: (String) First name of user
last_name: (String) Last name of user
22
23
systems which store data in tables that can be linked and used in a variety of
ways.
Referential integrity: Referential integrity refers to the series of processes that
make sure data is stored and used uniformly. Rules embedded into the
database’s structure about how foreign keys are used ensure that only
appropriate changes, additions, or deletions of data occur. Rules may include
constraints that eliminate the entry of duplicate data, guarantee that data
entry is accurate, and/or disallow the entry of data that doesn’t apply.
Domain integrity: Domain integrity is the collection of processes that ensure
the accuracy of each piece of data in a domain. In this context, a domain is a
set of acceptable values that a column is allowed to contain. It can include
constraints and other measures that limit the format, type, and amount of data
entered.
User-defined integrity: User-defined integrity involves the rules and constraints
created by the user to fit their particular needs. Sometimes entity, referential,
and domain integrity aren’t enough to safeguard data. Often, specific business
rules must be taken into account and incorporated into data integrity
measures.
4.3 Procedural Design
24
ER Diagram:
Security Issues:
I have used commercially reasonable safeguards to help secure a user's
information collected through the service. I have also state that Instagram takes
reasonable steps to verify a user's identity before granting them access to an
account. However, the policies do not clearly indicate whether or not a user's
25
data is encrypted while in transit or at rest. And also do not disclose how they
would notify users in the event of a data breach.
Chapter 4
Implementation And Testing
Code:
Main.dart
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/foundation.dart'; import
'package:flutter/material.dart';
import 'package:instagram_clone/providers/user_provider.dart';
import
'package:instagram_clone/responsive/mobile_screen_layout.dart'
; import
'package:instagram_clone/responsive/responsive_layout.dart';
import
26
'package:instagram_clone/responsive/web_screen_layout.dart';
import 'package:instagram_clone/screens/login_screen.dart';
import 'package:instagram_clone/utils/colors.dart'; import
'package:provider/provider.dart';
projectId: "instagram-6cd6f",
storageBucket: "instagram-6cd6f.appspot.com",
messagingSenderId: "507327205725",
appId: "1:507327205725:web:ca2c1b3e817695a03318b4"
),
); }
else {
await Firebase.initializeApp();
}
runApp(const MyApp());
}
@override
Widget build(BuildContext context) {
return MultiProvider( providers:
[
ChangeNotifierProvider(create: (_) =>
UserProvider(),),
],
child: MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Instagram Clone', theme:
ThemeData.dark().copyWith(
scaffoldBackgroundColor: mobileBackgroundColor,
),
home: StreamBuilder(
27
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) { if
(snapshot.connectionState ==
ConnectionState.active) {
// Checking if the snapshot has any data or not
if (snapshot.hasData) {
// if snapshot has data which means user is
logged in then we check the width of screen and accordingly
display the screen layout
return const ResponsiveLayout(
mobileScreenLayout: MobileScreenLayout(),
webScreenLayout: WebScreenLayout(),
);
} else if (snapshot.hasError) {
return Center(
child: Text('${snapshot.error}'),
);
}
}
mobile_screen.dart
import 'package:flutter/cupertino.dart'; import
'package:flutter/material.dart'; import
'package:instagram_clone/utils/colors.dart'; import
'package:instagram_clone/utils/global_variable.dart';
28
@override
State<MobileScreenLayout> createState() =>
_MobileScreenLayoutState();
}
@override void
initState() {
super.initState();
pageController = PageController();
}
@override void
dispose() {
super.dispose();
pageController.dispo
se();
}
@override
Widget build(BuildContext context) {
return Scaffold( body: PageView(
children: homeScreenItems,
controller: pageController,
onPageChanged: onPageChanged,
),
29
bottomNavigationBar: CupertinoTabBar(
backgroundColor: mobileBackgroundColor,
items: <BottomNavigationBarItem>[
BottomNavigationBarItem( icon: Icon(
Icons.home, color: (_page == 0) ?
primaryColor : secondaryColor, ),
label: '',
backgroundColor: primaryColor,
),
BottomNavigationBarItem(
icon: Icon( Icons.search,
color: (_page == 1) ? primaryColor : secondaryColor,
), label: '',
backgroundColor: primaryColor),
BottomNavigationBarItem( icon: Icon(
Icons.add_circle, color: (_page == 2) ?
primaryColor : secondaryColor, ),
label: '',
backgroundColor: primaryColor),
BottomNavigationBarItem(
icon: Icon( Icons.favorite,
color: (_page == 3) ? primaryColor :
secondaryColor, ), label:
'',
backgroundColor: primaryColor,
),
BottomNavigationBarItem(
icon: Icon( Icons.person,
color: (_page == 4) ? primaryColor :
secondaryColor, ), label:
'',
backgroundColor: primaryColor,
),
],
onTap: navigationTapped,
currentIndex: _page,
),
);
}
}
30
web_screen_layout.dart
import 'package:flutter/material.dart'; import
'package:flutter_svg/svg.dart'; import
'package:instagram_clone/utils/colors.dart'; import
'package:instagram_clone/utils/global_variable.dart';
@override
State<WebScreenLayout> createState() =>
_WebScreenLayoutState();
}
@override void
initState() {
super.initState();
pageController = PageController();
}
@override
31
32
login_screen.dart
import 'package:flutter/material.dart'; import
'package:flutter_svg/svg.dart';
import 'package:instagram_clone/resources/auth_methods.dart';
import
'package:instagram_clone/responsive/mobile_screen_layout.dart'
; import
'package:instagram_clone/responsive/responsive_layout.dart';
import
'package:instagram_clone/responsive/web_screen_layout.dart';
import 'package:instagram_clone/screens/signup_screen.dart';
import 'package:instagram_clone/utils/colors.dart'; import
'package:instagram_clone/utils/global_variable.dart'; import
'package:instagram_clone/utils/utils.dart'; import
'package:instagram_clone/widgets/text_filed_input.dart';
@override
_LoginScreenState createState() => _LoginScreenState();
}
@override void
dispose() {
super.dispose();
_emailController.dispose();
_passwordController.dispose();
}
33
_passwordController.text);
if (res == 'success') {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (context) => const ResponsiveLayout(
mobileScreenLayout: MobileScreenLayout(),
webScreenLayout: WebScreenLayout(),
),
),
(route) => false);
setState(() {
_isLoading = false;
}); } else {
setState(() {
_isLoading = false;
});
showSnackBar(context, res);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: SafeArea( child:
Container(
padding: MediaQuery.of(context).size.width >
webScreenSize
? EdgeInsets.symmetric(
horizontal: MediaQuery.of(context).size.width /
3)
: const EdgeInsets.symmetric(horizontal: 32),
width: double.infinity, child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [ Flexible( child:
Container(), flex: 2,
),
SvgPicture.asset(
'assets/ic_instagram.svg',
color: primaryColor, height:
64,
34
),
const SizedBox(
height: 64,
),
TextFieldInput(
hintText: 'Enter your email',
textInputType: TextInputType.emailAddress,
textEditingController: _emailController,
),
const SizedBox(
height: 24,
),
TextFieldInput(
hintText: 'Enter your password',
textInputType: TextInputType.text,
textEditingController: _passwordController,
isPass: true,
),
const SizedBox(
height: 24, ),
InkWell( child:
Container( child:
!_isLoading ?
const Text(
'Log in',
)
: const CircularProgressIndicator(
color: primaryColor,
),
width: double.infinity,
alignment: Alignment.center,
padding: const
EdgeInsets.symmetric(vertical: 12),
decoration: const ShapeDecoration(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4)),
),
color: blueColor,
),
),
onTap: loginUser,
),
const SizedBox(
height: 12, ),
Flexible( child:
35
Container(), flex:
2,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [ Container(
child: const Text( 'Dont have an
account?',
),
padding: const
EdgeInsets.symmetric(vertical: 8),
),
GestureDetector(
onTap: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const
SignupScreen(),
),
),
child: Container(
child: const Text(
' Signup.', style:
TextStyle(
fontWeight: FontWeight.bold,
),
), padding:
const
EdgeInsets.symmetric(vertical: 8),
),
),
],
),
],
),
),
),
);
}
}
signup_screen.dart
import 'dart:typed_data';
36
@override
_SignupScreenState createState() => _SignupScreenState();
}
@override void
dispose() {
super.dispose();
_emailController.dispose();
_passwordController.dispose();
_usernameController.dispose();
}
37
setState(() {
_isLoading = true;
});
selectImage() async {
Uint8List im = await pickImage(ImageSource.gallery);
// set state because we need to display the image we
selected on the circle avatar setState(() {
_image = im;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
38
body: SafeArea(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 32),
width: double.infinity, child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [ Flexible( child:
Container(), flex: 2,
),
SvgPicture.asset(
'assets/ic_instagram.svg',
color: primaryColor, height:
50,
),
const SizedBox(
height: 10,
), Stack(
children: [ _image !=
null ? CircleAvatar(
radius: 64,
backgroundImage: MemoryImage(_image!),
backgroundColor: Colors.red,
)
: const CircleAvatar(
radius: 50,
backgroundImage: NetworkImage(
'https://i.stack.imgur.com/l60Hf
.png'),
backgroundColor: Colors.red,
),
Positioned( bottom: -10,
left: 80, child:
IconButton( onPressed:
selectImage,
icon: const Icon(Icons.add_a_photo),
),
)
],
), const
SizedBox(
height: 24,
),
TextFieldInput(
hintText: 'Enter your username',
textInputType: TextInputType.text,
textEditingController: _usernameController,
39
),
const SizedBox(
height: 10,
),
TextFieldInput(
hintText: 'Enter your email',
textInputType: TextInputType.emailAddress,
textEditingController: _emailController,
),
const SizedBox(
height: 10,
),
TextFieldInput(
hintText: 'Enter your password',
textInputType: TextInputType.text,
textEditingController: _passwordController,
isPass: true,
),
const SizedBox(
height: 10,
),
TextFieldInput(
hintText: 'Enter your bio',
textInputType: TextInputType.text,
textEditingController: _bioController,
), const
SizedBox( height:
10, ),
InkWell( child:
Container( child:
!_isLoading ?
const Text(
'Sign up',
)
: const CircularProgressIndicator(
color: primaryColor,
),
height: 10, width:
double.infinity, alignment:
Alignment.center,
padding: const
EdgeInsets.symmetric(vertical: 12),
decoration: const ShapeDecoration(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4)),
40
),
color: blueColor,
),
),
onTap: signUpUser,
),
const SizedBox(
height: 12, ),
Flexible( child:
Container(), flex:
2,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [ Container(
child: const Text(
'Already have an account?',
),
padding: const
EdgeInsets.symmetric(vertical: 8),
),
GestureDetector(
onTap: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const
LoginScreen(),
),
),
child: Container(
child: const Text(
' Login.', style:
TextStyle(
fontWeight: FontWeight.bold,
),
), padding:
const
EdgeInsets.symmetric(vertical: 8),
),
),
],
),
],
),
),
41
),
);
}
}
profile_screen.dart
import 'dart:typed_data';
@override
_SignupScreenState createState() => _SignupScreenState();
}
42
@override void
dispose() {
super.dispose();
_emailController.dispose();
_passwordController.dispose();
_usernameController.dispose();
}
selectImage() async {
43
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: SafeArea( child:
Container(
padding: const EdgeInsets.symmetric(horizontal: 32),
width: double.infinity, child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [ Flexible( child:
Container(), flex: 2,
),
SvgPicture.asset(
'assets/ic_instagram.svg',
color: primaryColor, height:
50,
),
const SizedBox(
height: 10,
), Stack(
children: [ _image !=
null ? CircleAvatar(
radius: 64,
backgroundImage: MemoryImage(_image!),
backgroundColor: Colors.red,
)
: const CircleAvatar(
radius: 50,
backgroundImage: NetworkImage(
'https://i.stack.imgur.com/l60Hf
.png'),
backgroundColor: Colors.red,
),
Positioned( bottom: -10,
left: 80, child:
IconButton( onPressed:
selectImage,
44
45
)
: const CircularProgressIndicator(
color: primaryColor,
),
height: 10, width:
double.infinity, alignment:
Alignment.center,
padding: const
EdgeInsets.symmetric(vertical: 12),
decoration: const ShapeDecoration(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4)),
),
color: blueColor,
),
),
onTap: signUpUser,
),
const SizedBox(
height: 12, ),
Flexible( child:
Container(), flex:
2,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [ Container(
child: const Text(
'Already have an account?',
),
padding: const
EdgeInsets.symmetric(vertical: 8),
),
GestureDetector(
onTap: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const
LoginScreen(),
),
),
child: Container(
child: const Text( '
Login.', style:
TextStyle(
fontWeight: FontWeight.bold,
46
),
), padding:
const
EdgeInsets.symmetric(vertical: 8),
),
),
],
),
],
),
),
),
}
} auth_method.dart
import 'dart:typed_data';
import 'package:instagram_clone/models/user.dart' as model;
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart'; import
'package:instagram_clone/resources/storage_methods.dart';
class AuthMethods {
final FirebaseFirestore _firestore =
FirebaseFirestore.instance;
final FirebaseAuth _auth = FirebaseAuth.instance;
DocumentSnapshot documentSnapshot =
await
_firestore.collection('users').doc(currentUser.uid).get();
return model.User.fromSnap(documentSnapshot);
}
// Signing Up User
Future<String> signUpUser({
required String email,
required String password,
required String username,
47
String photoUrl =
await
StorageMethods().uploadImageToStorage('profilePics', file,
false);
model.User _user = model.User(
username: username, uid:
cred.user!.uid, photoUrl:
photoUrl, email: email,
bio: bio, followers: [],
following: [],
);
res = "success";
} else {
res = "Please enter all the fields";
}
} catch (err) {
return err.toString();
}
return res;
}
48
// logging in user
Future<String> loginUser({
required String email, required
String password,
}) async {
String res = "Some error Occurred";
try {
if (email.isNotEmpty || password.isNotEmpty) {
// logging in user with email and password
await _auth.signInWithEmailAndPassword(
email: email, password: password,
);
res = "success";
} else {
res = "Please enter all the fields";
}
} catch (err) {
return err.toString();
}
return res;
}
class FireStoreMethods {
final FirebaseFirestore _firestore =
FirebaseFirestore.instance;
49
50
});
}
res = 'success';
} catch (err) { res =
err.toString();
}
return res;
}
// Post comment
Future<String> postComment(String postId, String text,
String uid,
String name, String profilePic) async {
String res = "Some error occurred"; try {
if (text.isNotEmpty) {
// if the likes list contains the user uid, we need to
remove it
String commentId = const Uuid().v1();
_firestore
.collection('posts')
.doc(postId)
.collection('comments')
.doc(commentId)
.set({
'profilePic': profilePic,
'name': name,
'uid': uid,
'text': text,
'commentId': commentId,
'datePublished': DateTime.now(),
});
res = 'success';
} else {
res = "Please enter text";
}
} catch (err) {
res = err.toString();
}
return res;
}
// Delete Post
Future<String> deletePost(String postId) async {
51
Future<void> followUser(
String uid,
String followId
) async { try {
DocumentSnapshot snap = await
_firestore.collection('users').doc(uid).get();
List following = (snap.data()! as dynamic)['following'];
if(following.contains(followId)) {
await
_firestore.collection('users').doc(followId).update({
'followers': FieldValue.arrayRemove([uid])
});
await _firestore.collection('users').doc(uid).update({
'following': FieldValue.arrayRemove([followId])
});
} else {
await
_firestore.collection('users').doc(followId).update({
'followers': FieldValue.arrayUnion([uid])
});
await _firestore.collection('users').doc(uid).update({
'following': FieldValue.arrayUnion([followId])
});
}
} catch(e) {
print(e.toString());
}
}
}
52
53
Chapter 5
Result and Discussions
Web :
Android app:
54
55
56
57
Future Enhancement :
To connect with MircoSoft sql server for unlimated for data.
58
Reference:
Youtube.com
Google.com Github.com
https://github.com/RivaanRanawat/instagram-flutter-clone