Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolved Error:The operator '[]' isn't defined” error when using .data[] in flutter firestore #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"cloud_firestore","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\cloud_firestore-0.13.7\\\\","dependencies":["firebase_core"]},{"name":"firebase_analytics","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_analytics-5.0.16\\\\","dependencies":[]},{"name":"firebase_auth","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_auth-0.16.1\\\\","dependencies":["firebase_core"]},{"name":"firebase_core","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-0.4.5\\\\","dependencies":[]},{"name":"firebase_storage","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_storage-3.1.6\\\\","dependencies":["firebase_core"]},{"name":"google_sign_in","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_sign_in-4.5.4\\\\","dependencies":[]},{"name":"image_picker","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.6.7+11\\\\","dependencies":[]}],"android":[{"name":"cloud_firestore","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\cloud_firestore-0.13.7\\\\","dependencies":["firebase_core"]},{"name":"firebase_analytics","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_analytics-5.0.16\\\\","dependencies":[]},{"name":"firebase_auth","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_auth-0.16.1\\\\","dependencies":["firebase_core"]},{"name":"firebase_core","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-0.4.5\\\\","dependencies":[]},{"name":"firebase_storage","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_storage-3.1.6\\\\","dependencies":["firebase_core"]},{"name":"flutter_plugin_android_lifecycle","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-1.0.11\\\\","dependencies":[]},{"name":"google_sign_in","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_sign_in-4.5.4\\\\","dependencies":[]},{"name":"image_picker","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.6.7+11\\\\","dependencies":["flutter_plugin_android_lifecycle"]}],"macos":[{"name":"cloud_firestore","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\cloud_firestore-0.13.7\\\\","dependencies":["firebase_core"]},{"name":"firebase_auth","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_auth-0.16.1\\\\","dependencies":["firebase_core"]},{"name":"firebase_core","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-0.4.5\\\\","dependencies":[]},{"name":"firebase_storage","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_storage-3.1.6\\\\","dependencies":["firebase_core"]}],"linux":[],"windows":[],"web":[{"name":"cloud_firestore_web","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\cloud_firestore_web-0.1.1+2\\\\","dependencies":[]},{"name":"firebase_analytics_web","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_analytics_web-0.1.1\\\\","dependencies":[]},{"name":"firebase_auth_web","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_auth_web-0.1.3+1\\\\","dependencies":[]},{"name":"firebase_core_web","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core_web-0.1.1+2\\\\","dependencies":[]},{"name":"google_sign_in_web","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_sign_in_web-0.9.2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"cloud_firestore","dependencies":["firebase_core","cloud_firestore_web"]},{"name":"cloud_firestore_web","dependencies":["firebase_core"]},{"name":"firebase_analytics","dependencies":["firebase_analytics_web"]},{"name":"firebase_analytics_web","dependencies":[]},{"name":"firebase_auth","dependencies":["firebase_core","firebase_auth_web"]},{"name":"firebase_auth_web","dependencies":[]},{"name":"firebase_core","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","dependencies":[]},{"name":"firebase_storage","dependencies":["firebase_core"]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_sign_in","dependencies":["google_sign_in_web"]},{"name":"google_sign_in_web","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle"]}],"date_created":"2020-10-02 10:42:41.447808","version":"1.22.0"}
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ android {

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "mohak.fchat.app"
applicationId "mohakApoorv.fchat.app"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
Expand Down
33 changes: 9 additions & 24 deletions android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,37 @@
{
"project_info": {
"project_number": "910539670225",
"firebase_url": "https://flutterchatapp-a28f7.firebaseio.com",
"project_id": "flutterchatapp-a28f7",
"storage_bucket": "flutterchatapp-a28f7.appspot.com"
"project_number": "171126428694",
"firebase_url": "https://mohakchat-416fc.firebaseio.com",
"project_id": "mohakchat-416fc",
"storage_bucket": "mohakchat-416fc.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:910539670225:android:803bd2a516dadbec",
"mobilesdk_app_id": "1:171126428694:android:66239cb3042c24e741d137",
"android_client_info": {
"package_name": "mohak.fchat.app"
"package_name": "mohakApoorv.fchat.app"
}
},
"oauth_client": [
{
"client_id": "910539670225-3gif84a78g1ndkaiahruasnh63m8mtmo.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "mohak.fchat.app",
"certificate_hash": "c0367f976f474b02d25e79d452dd3124a5ce8df9"
}
},
{
"client_id": "910539670225-pbbhu109govqb0h8mjjc7dbhrkqj8tnd.apps.googleusercontent.com",
"client_id": "171126428694-9fnukbc9j791q58e09so3mb86bnfbmpe.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyD8GFBCF0_4XfVHrU_erYryodtAv6TDqOk"
"current_key": "AIzaSyAQv6VC7yr8BcbGJeC_pSVuDv67f3FsZUI"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 2,
"other_platform_oauth_client": [
{
"client_id": "910539670225-pbbhu109govqb0h8mjjc7dbhrkqj8tnd.apps.googleusercontent.com",
"client_id": "171126428694-9fnukbc9j791q58e09so3mb86bnfbmpe.apps.googleusercontent.com",
"client_type": 3
}
]
},
"ads_service": {
"status": 2
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
//classpath 'com.google.gms:google-services:4.0.1'
classpath 'com.google.gms:google-services:4.2.0'
// classpath 'com.google.gms:google-services:4.2.0'
classpath 'com.google.gms:google-services:4.3.4'
}
}

Expand Down
1 change: 1 addition & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.enableJetifier=true
android.useAndroidX=true
android.enableR8=true
15 changes: 15 additions & 0 deletions ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=C:\src\flutter\flutter"
export "FLUTTER_APPLICATION_PATH=C:\Users\apoor\Flutter-Clones\chat-app-flutter"
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build\ios"
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
export "FLUTTER_FRAMEWORK_DIR=C:\src\flutter\flutter\bin\cache\artifacts\engine\ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=false"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.packages"
9 changes: 5 additions & 4 deletions lib/all_users_screen.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import 'dart:async';
import 'dart:io';

import 'package:chat_app/chat_screen.dart';
import 'package:chat_app/home_page.dart';
import 'package:chat_app/main.dart';
import 'package:chat_app/models/user_details.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:google_sign_in/google_sign_in.dart';
//Unused Imports
// import 'dart:io';
// import 'package:chat_app/home_page.dart';
// import 'package:chat_app/models/user_details.dart';

class AllUsersScreen extends StatefulWidget {
static const String id = 'all_users_screen';
_AllUsersScreenState createState() => _AllUsersScreenState();
}

Expand Down
12 changes: 8 additions & 4 deletions lib/chat_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:image_picker/image_picker.dart';
import 'package:firebase_storage/firebase_storage.dart';

class ChatScreen extends StatefulWidget {
static const String id = 'chat_screen';
String name;
String photoUrl;
String receiverUid;
Expand Down Expand Up @@ -39,7 +40,7 @@ class _ChatScreenState extends State<ChatScreen> {
@override
void initState() {
super.initState();

_messageController = TextEditingController();
getUID().then((user) {
setState(() {
Expand Down Expand Up @@ -304,8 +305,9 @@ class _ChatScreenState extends State<ChatScreen> {
Padding(
padding: const EdgeInsets.all(12.0),
child: Row(
mainAxisAlignment: snapshot['senderUid'] == _senderuid?
MainAxisAlignment.end : MainAxisAlignment.start,
mainAxisAlignment: snapshot['senderUid'] == _senderuid
? MainAxisAlignment.end
: MainAxisAlignment.start,
children: <Widget>[
snapshot['senderUid'] == _senderuid
? CircleAvatar(
Expand Down Expand Up @@ -351,7 +353,9 @@ class _ChatScreenState extends State<ChatScreen> {
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => FullScreenImage(photoUrl: snapshot['photoUrl'],)));
builder: (context) => FullScreenImage(
photoUrl: snapshot['photoUrl'],
)));
}),
child: Hero(
tag: snapshot['photoUrl'],
Expand Down
60 changes: 30 additions & 30 deletions lib/full_screen_image.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';

class FullScreenImage extends StatefulWidget {

static const String id = 'full_screen_image';
String photoUrl;
FullScreenImage({this.photoUrl});

Expand All @@ -13,35 +13,35 @@ class _FullScreenImageState extends State<FullScreenImage> {
Widget build(BuildContext context) {
return Scaffold(
body: SizedBox.expand(
child: Stack(
children: <Widget>[
Align(
alignment: Alignment.center,
child: Hero(
tag: widget.photoUrl,
child: Image.network(widget.photoUrl),
),
child: Stack(
children: <Widget>[
Align(
alignment: Alignment.center,
child: Hero(
tag: widget.photoUrl,
child: Image.network(widget.photoUrl),
),
),
Align(
alignment: Alignment.topCenter,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
AppBar(
elevation: 0.0,
backgroundColor: Colors.transparent,
leading: IconButton(
icon: Icon(Icons.close, color: Colors.black),
onPressed: () => Navigator.pop(context),
),
)
],
),
Align(
alignment: Alignment.topCenter,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
AppBar(
elevation: 0.0,
backgroundColor: Colors.transparent,
leading: IconButton(
icon: Icon(Icons.close, color: Colors.black),
onPressed: () => Navigator.pop(context),
),
)
],
),
)
],
),
)
],
),
);
),
);
}
}
}
5 changes: 3 additions & 2 deletions lib/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:cloud_firestore/cloud_firestore.dart';
import 'dart:async';

class HomePage extends StatefulWidget {
static const String id = 'home_page';
_HomePageState createState() => _HomePageState();
}

Expand All @@ -26,9 +27,9 @@ class _HomePageState extends State<HomePage> {
AuthCredential authCredential = GoogleAuthProvider.getCredential(
idToken: _signInAuthentication.idToken,
accessToken: _signInAuthentication.accessToken);

//add ().user
FirebaseUser user =
await _firebaseAuth.signInWithCredential(authCredential);
(await _firebaseAuth.signInWithCredential(authCredential)).user;
return user;
}

Expand Down
15 changes: 13 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,19 @@ class MyAppState extends State<MyApp> {
return MaterialApp(
title: "Chat App",
theme: ThemeData(primarySwatch: Colors.red),
routes: <String, WidgetBuilder>{
'/chatscreen': (BuildContext context) => new AllUsersScreen(),
// routes: <String, WidgetBuilder>{
// '/chatscreen': (BuildContext context) => new AllUsersScreen(),
// },
routes: {
// SplashScreen.id: (context) => SplashScreen(),
AllUsersScreen.id: (context) => AllUsersScreen(),
HomePage.id: (context) => HomePage(),
// RegistrationScreen.id: (context) => RegistrationScreen(),
// MyHomePage.id: (context) => MyHomePage(),
// NotificationScreen.id: (context) => NotificationScreen(),
// AboutPage.id: (context) => AboutPage(),
// //Search User Screen
// SeachAppBarRecipe.id: (context) => SeachAppBarRecipe(),
},
home: isLoggedIn == true ? AllUsersScreen() : HomePage(),
);
Expand Down
32 changes: 27 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,47 @@ dependencies:

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
# cupertino_icons: ^0.1.2
# firebase_auth:
# google_sign_in:
# cloud_firestore:
# firebase_storage:
# image_picker:
cupertino_icons: ^0.1.2
firebase_auth:
google_sign_in:
image_picker:

firebase_auth:
cloud_firestore:
firebase_storage:
image_picker:

# cupertino_icons: ^0.1.2
# flutter_signin_button: ^1.0.0
# modal_progress_hud: ^0.1.3
# animated_text_kit: ^1.3.0
# url_launcher: ^4.0.1
# share: ^0.6.3+6
# Firebase
firebase_core: ^0.4.3+2
# firebase_auth: ^0.15.5+2
firebase_analytics: ^5.0.11
# cloud_firestore: ^0.13.4+2
# Google SignIn
# google_sign_in: ^4.1.4
# rx dart
rxdart: ^0.21.0
# firebase_storage: ^3.1.5
# image_picker: ^0.6.4
# english_words:

dev_dependencies:
flutter_test:
sdk: flutter


# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
Expand Down