Coder Social home page Coder Social logo

rivaanranawat / instagram-flutter-clone Goto Github PK

View Code? Open in Web Editor NEW
855.0 22.0 469.0 677 KB

Responsive Instagram Clone developed with Flutter & Firebase

Home Page: https://youtu.be/BBccK1zTgxw

Kotlin 0.16% Ruby 1.58% Swift 0.47% Objective-C 0.04% Dart 93.10% HTML 4.63%
flutter firebase flutterfire

instagram-flutter-clone's Introduction

Instagram Clone

A completely Responsive Instagram App- Works on Android, iOS & Web!

Features

  • Responsive Instagram UI
  • Email & Password Authentication
  • Share Posts with Caption
  • Display Posts with Caption
  • Like & Comment on Posts
  • Search Users
  • Follow Users
  • Display User Posts, Followers & Following
  • EVERYTHING REAL TIME
  • Sign Out

YouTube

I have created a tutorial based on this, do check it out on my channel Rivaan Ranawat

Youtube Tutorial Image

Installation

After cloning this repository, migrate to instagram-flutter-clone folder. Then, follow the following steps:

  • Create Firebase Project
  • Enable Authentication
  • Make Firestore Rules
  • Create Android, iOS & Web Apps
  • Take Web FirebaseOptions and put it in main function in main.dart file replacing my keys (My keys wont work as I deleted my project) Then run the following commands to run your app:
  flutter pub get
  open -a simulator (to get iOS Simulator)
  flutter run
  flutter run -d chrome --web-renderer html (to see the best output)

Tech Used

Server: Firebase Auth, Firebase Storage, Firebase Firestore

Client: Flutter, Provider

Feedback

If you have any feedback, please reach out to me at [email protected]

instagram-flutter-clone's People

Contributors

rivaanranawat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

instagram-flutter-clone's Issues

Can any user delete the post from the feed instead of just the post Owner ? Is it just happening with me ?

ListView( padding: const EdgeInsets.symmetric(vertical: 16), shrinkWrap: true, children: ['Delete'] .map( (e) => InkWell( onTap: () async { FirestoreMethods().deletePost( widget.snap['postId'], ); Navigator.of(context).pop(); }, child: Container( padding: const EdgeInsets.symmetric( vertical: 12, horizontal: 16, ), child: Text(e), ), ), )

As we don't check for, If logged in user is same as the user who posted, It causes this bug.

Image Selection Issue

Whenever I choose to select an image from Gallery, the prompt to view my photos opens up correctly. When I cancel this prompt and do not choose a photo, I get an error saying that Uint8List cannot be null. @RivaanRanawat is this something that can be fixed?

Excellent tutorial by the way!!!

type 'Null' is not a subtype of type 'String'

Error showing in debug console
E/flutter ( 9425): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a subtype of type 'String'
E/flutter ( 9425): #0 User.fromSnap
package:insta_clone/models/user.dart:26
E/flutter ( 9425): #1 AuthMethods.getUserDetails
package:insta_clone/resources/auth_methods.dart:19
E/flutter ( 9425):
E/flutter ( 9425): #2 UserProvider.refreshUser
package:insta_clone/providers/user_provider.dart:13
E/flutter ( 9425):
E/flutter ( 9425): #3 _ResponsiveLayoutState.addData
package:insta_clone/responsive/responsive_layout.dart:28
E/flutter ( 9425):

From user.dart
static User fromSnap(DocumentSnapshot snap) {
var snapshot = snap.data() as Map<String, dynamic>;
return User(
username: snapshot['username'],
uid: snapshot['uid'],
email: snapshot['email'],
photoUrl: snapshot['photoUrl'], (error putting here on ['photoUrl')
followers: snapshot['followers'],
following: snapshot['following'],
);
}

From auth_methods.dart
DocumentSnapshot documentSnapshot =
await _firestore.collection('users').doc(currentUser.uid).get();

return model.User.fromSnap(documentSnapshot); (error pointing here on fromSnap)

}
please help stuck here from last 1 week, i have tried solutions to solve that red screen problem, but after that it just showing cirular progess indicator, i have deleted users from database but after that too its showing errors.

flutter.compileSdkVersion question

In the android/app/build.gradle you refernced flutter.compileSdkVersion (this appears to be read from somewhere else?, how/where is the compileSdkVersion set?)

Likewise you referenced flutter.targetSdkVersion (where does this come from?)

postId

I can't get the post document using the uuid generated id in the field 'postId' ! Am I missing something?

To know more about flutter

Sir i am bit confused in this clone you write backend (using dart ) .When i was in interview interviewer asked to me is this we can write backend in dart or not i said yes(interviewer is not satisfied with it)If you can give me answer what is correct then it will be lot more beneficial for us .
if you said explain it correctly so i can handle this type of situation.
I hope you reply of it
Thanking Sir

Error Project

Because xml 6.3.0 depends on meta ^1.9.0 and no versions of xml match >6.3.0 <7.0.0, xml ^6.3.0 requires meta ^1.9.0.
And because every version of flutter from sdk depends on meta 1.8.0, flutter from sdk is incompatible with xml ^6.3.0.
And because vector_graphics_compiler 1.1.7 depends on xml ^6.3.0 and no versions of vector_graphics_compiler match >1.1.7 <2.0.0, flutter from sdk is incompatible with vector_graphics_compiler ^1.1.7.
And because flutter_svg 2.0.7 depends on vector_graphics_compiler ^1.1.7 and no versions of flutter_svg match >2.0.7 <3.0.0, flutter from sdk is incompatible with flutter_svg ^2.0.7.
So, because instagram_clone_flutter depends on both flutter from sdk and flutter_svg ^2.0.7, version solving failed.
pub get failed
command: "C:\src\flutter\bin\cache\dart-sdk\bin\dart __deprecated_pub --directory . get --example"
pub env: {
"FLUTTER_ROOT": "C:\src\flutter",
"PUB_ENVIRONMENT": "flutter_cli:verify:run",
"PUB_CACHE": "C:\Users\mansi\AppData\Local\Pub\Cache",
}
exit code: 1

This error is coming when trying to run this

class AuthMetods methods conditions

I think you have made a mistake on both methods loginUser and signUpUser you have used operator OR instead of AND.
therefore the fields are not required.

`
if (email.isNotEmpty || password.isNotEmpty || username.isNotEmpty || bio.isNotEmpty || file != null) {

return "Only one fiield are required with the || operator";

}
`

SignUpScreen

Hi everyone,
the _image is null, so the signUpUser cannot be triggered if the user does not enter an image. this leads to an error by the postfix ! operator. _CastError (Null check operator used on a null value).

String res = await AuthMetods().signUpUser( email: _emailController.text, bio: _bioController.text, password: _passwordController.text, username: _usernameController.text, file: _image!, );

If we follow the logic of the application the user will have a default image.

how can we manage this with Firebase ? if the user doesn't enter an image ?

Fiebase issue.. please help

E/flutter ( 4923): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
E/flutter ( 4923): #0 _SignupScreenState.signUpUser (package:genuno_flutter/screens/signup_screen.dart:50:21)
E/flutter ( 4923): #1 _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1154:21)
E/flutter ( 4923): #2 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:275:24)
E/flutter ( 4923): #3 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:654:11)
E/flutter ( 4923): #4 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:311:5)
E/flutter ( 4923): #5 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:244:7)
E/flutter ( 4923): #6 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:630:9)
E/flutter ( 4923): #7 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98:12)
E/flutter ( 4923): #8 PointerRouter._dispatchEventToRoutes. (package:flutter/src/gestures/pointer_router.dart:143:9)
E/flutter ( 4923): #9 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
E/flutter ( 4923): #10 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
E/flutter ( 4923): #11 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7)
E/flutter ( 4923): #12 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:488:19)
E/flutter ( 4923): #13 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:468:22)
E/flutter ( 4923): #14 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:333:11)
E/flutter ( 4923): #15 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:413:7)
E/flutter ( 4923): #16 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:376:5)
E/flutter ( 4923): #17 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:323:7)
E/flutter ( 4923): #18 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:292:9)
E/flutter ( 4923): #19 _invoke1 (dart:ui/hooks.dart:186:13)
E/flutter ( 4923): #20 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:424:7)
E/flutter ( 4923): #21 _dispatchPointerDataPacket (dart:ui/hooks.dart:119:31)
E/flutter ( 4923):
D/EGL_emulation( 4923): app_time_stats: avg=13.76ms min=6.28ms max=74.88ms count=52
D/EGL_emulation( 4923): app_time_stats: avg=12.17ms min=6.24ms max=49.54ms count=55
D/EGL_emulation( 4923): app_time_stats: avg=12.64ms min=5.62ms max=27.54ms count=58
D/EGL_emulation( 4923): app_time_stats: avg=14.42ms min=6.28ms max=52.10ms count=47
D/EGL_emulation( 4923): app_time_stats: avg=13.17ms min=5.95ms max=63.33ms count=54
D/EGL_emulation( 4923): app_time_stats: avg=16.09ms min=6.24ms max=73.82ms count=47
D/EGL_emulation( 4923): app_time_stats: avg=21.36ms min=8.65ms max=133.82ms count=31
D/EGL_emulation( 4923): app_time_stats: avg=17.32ms min=9.37ms max=40.35ms count=50
D/CompatibilityChangeReporter( 4923): Compat change id reported: 78294732; UID 10184; state: ENABLED
D/EGL_emulation( 4923): app_time_stats: avg=18.86ms min=8.45ms max=66.49ms count=42
D/EGL_emulation( 4923): app_time_stats: avg=25.37ms min=6.24ms max=323.78ms count=30
I/FirebaseAuth( 4923): Creating user with [email protected] with empty reCAPTCHA token
W/System ( 4923): Ignoring header X-Firebase-Locale because its value was null.
D/EGL_emulation( 4923): app_time_stats: avg=17.11ms min=8.17ms max=70.96ms count=46
D/TrafficStats( 4923): tagSocket(133) with statsTag=0xffffffff, statsUid=-1
W/System ( 4923): Ignoring header X-Firebase-Locale because its value was null.
D/EGL_emulation( 4923): app_time_stats: avg=17.20ms min=7.15ms max=57.32ms count=51
D/FirebaseAuth( 4923): Notifying id token listeners about user ( 9RB10r5xI2ZtZ9fvFRutYfWFLyw2 ).
D/FirebaseAuth( 4923): Notifying auth state listeners about user ( 9RB10r5xI2ZtZ9fvFRutYfWFLyw2 ).
E/AndroidRuntime( 4923): FATAL EXCEPTION: pool-4-thread-5
E/AndroidRuntime( 4923): Process: com.example.genuno_flutter, PID: 4923
E/AndroidRuntime( 4923): java.lang.IllegalArgumentException: The storage Uri cannot contain a path element.
E/AndroidRuntime( 4923): at com.google.firebase.storage.FirebaseStorage.getInstanceImpl(FirebaseStorage.java:90)
E/AndroidRuntime( 4923): at com.google.firebase.storage.FirebaseStorage.getInstance(FirebaseStorage.java:173)
E/AndroidRuntime( 4923): at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin.getStorage(FlutterFirebaseStoragePlugin.java:156)
E/AndroidRuntime( 4923): at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin.getReference(FlutterFirebaseStoragePlugin.java:179)
E/AndroidRuntime( 4923): at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin.lambda$taskPutData$8$io-flutter-plugins-firebase-storage-FlutterFirebaseStoragePlugin(FlutterFirebaseStoragePlugin.java:363)
E/AndroidRuntime( 4923): at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin$$ExternalSyntheticLambda7.run(Unknown Source:6)

E/AndroidRuntime( 4923): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
E/AndroidRuntime( 4923): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
E/AndroidRuntime( 4923): at java.lang.Thread.run(Thread.java:1012)
I/Process ( 4923): Sending signal. PID: 4923 SIG: 9
Lost connection to device.

Exited.

To know more about flutter

Sir i am bit confused in this clone you write backend (using dart ) .When i was in interview interviewer asked to me is this we can write backend in dart or not i said yes(interviewer is not satisfied with it)If you can give me answer what is correct then it will be lot more beneficial for us .
if you said explain it correctly so i can handle this type of situation.
I hope you reply of it
Thanking Sir

signup bio text field fix

FOR ANDROID
When we focus on Bio text field inside signUp page the textflied does not go up that is we can not see what we are typing
if we wrap the container inside the safearea in singleChildScrollView() the issue will be fixed
plus we can add physics of bouncingscrollphysics so that it looks clean

here my is code for just UI
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:instagram/utils/color.dart';
import 'package:instagram/widgets/text_fill_input.dart';

class SignUpScreen extends StatefulWidget {
const SignUpScreen({Key? key}) : super(key: key);

@OverRide
_SignUpScreenState createState() => _SignUpScreenState();
}

class _SignUpScreenState extends State {
final TextEditingController _emailController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
final TextEditingController _bioController = TextEditingController();
final TextEditingController _usernameController = TextEditingController();
@OverRide
void dispose() {
// TODO: implement dispose
super.dispose();
_emailController.dispose();
_passwordController.dispose();
_bioController.dispose();
_usernameController.dispose();
}

@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 32),
child: Container(
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// Flexible(
// child: Container(),
// flex: 2,
// ),
//svg image
SvgPicture.asset(
'assets/ic_instagram.svg',
color: primaryColor,
height: 64,
),
const SizedBox(
height: 64,
),
//circle avaatar
InkWell(
onTap: () {},
borderRadius: BorderRadius.circular(100),
child: const Padding(
padding: EdgeInsets.all(8.0),
child: CircleAvatar(
radius: 64,
backgroundImage: NetworkImage(
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSyRQMnGzDaaUvx0wbRLJnc_JzEz_VCs44CBY-UOvh0kaacPJEAgPnXWQCYf2WroEwfl7w&usqp=CAU'),
),
),
),
const SizedBox(
height: 24,
),
//text field for username
TextFieldInput(
textEditingController: _usernameController,
hintText: 'Enter Your Username',
textInputType: TextInputType.text),
const SizedBox(
height: 24,
),
//text field for email
TextFieldInput(
textEditingController: _emailController,
hintText: 'Enter Your Email',
textInputType: TextInputType.emailAddress),
const SizedBox(
height: 24,
),
//text fiel for password
TextFieldInput(
textEditingController: _passwordController,
hintText: 'Enter Your Password',
textInputType: TextInputType.text,
isPass: true,
),
const SizedBox(
height: 24,
),
//text field for bio
TextFieldInput(
textEditingController: _bioController,
hintText: 'Enter Your Bio',
textInputType: TextInputType.text),
const SizedBox(
height: 24,
),
//button login
InkWell(
onTap: () {},
child: Container(
child: const Text("Sign up"),
width: double.infinity,
alignment: Alignment.center,
padding: const EdgeInsets.symmetric(vertical: 12),
decoration: ShapeDecoration(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4),
),
color: blueColor,
),
),
),
const SizedBox(
height: 12,
),
// Flexible(
// child: Container(),
// flex: 2,
// ),
//transition to signing up
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Container(
child: const Text("Don't have an account?"),
),
),
GestureDetector(
onTap: () {},
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Container(
child: const Text(
" Sign up.",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
),
)
],
)
],
),
),
),
),
));
}
}

Null check operator used on a null value from userProvider

Hello everyone, I am encountering the issue of null check, I followed the tutorial video, around 3:17:28, when I switched the networkImage with user.photoUrl:
image

The null check error was thrown from the userProvider, error message: Exception has occurred. _CastError (Null check operator used on a null value), my code of userProvider.dart:
image

I have already tried upgrading the pub version, or using the final Userprovider userprovider instead of User, the result is either showing nothing after pressing the upload icon, or throwing the error of: Exception has occurred. _CastError (Null check operator used on a null value).

I would like to know how to resolve it, Thanks!

Posts - Don't have the good lenght in SearchScreern

When I go to an other profil, the number of the posts keep the value of the current user connected.
And the other data like Followers and Following is working.

====> Resolve :

Change your variable "postSnap" by :

var postSnap = await FirebaseFirestore.instance
          .collection('posts')
          .where('uid', isEqualTo: widget.uid)
          .get();

Search Screen StateError (Bad state: field does not exist within the DocumentSnapshotPlatform)

If you get "StateError (Bad state: field does not exist within the DocumentSnapshotPlatform)" on search screen at :

(snapshot.data! as dynamic).docs[index] ['photoUrl'],

you should use:
if (snapshot.connectionState == ConnectionState.waiting)

instead of :
if (!snapshot.hasData)

It looks like hasdata returns true for any non-null data, and [] is non-null data, hence hasdata will return true while the snapshot is still in a waiting state.

Always use ConnectionState.waiting, never use junky hasdata which actually means "not null".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.