This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <key>CFBundleURLTypes</key> | |
| <array> | |
| <dict> | |
| <key>CFBundleTypeRole</key> | |
| <string>Editor</string> | |
| <key>CFBundleURLSchemes</key> | |
| <array> | |
| <string>[YOUR_REVERSED_CLIENT_ID]</string> | |
| </array> | |
| </dict> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| GoogleSignInAccount googleUser = await googleSignIn.signIn(); | |
| GoogleSignInAuthentication googleAuth = await googleUser.authentication; | |
| final AuthCredential credential = GoogleAuthProvider.getCredential( | |
| accessToken: googleAuth.accessToken, | |
| idToken: googleAuth.idToken, | |
| ); | |
| FirebaseUser firebaseUser = (await firebaseAuth.signInWithCredential(credential)).user; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (firebaseUser != null) { | |
| // Check is already sign up | |
| final QuerySnapshot result = | |
| await Firestore.instance.collection('users').where('id', isEqualTo: firebaseUser.uid).getDocuments(); | |
| final List < DocumentSnapshot > documents = result.documents; | |
| if (documents.length == 0) { | |
| // Update data to server if new user | |
| Firestore.instance.collection('users').document(firebaseUser.uid).setData( | |
| { 'nickname': firebaseUser.displayName, 'photoUrl': firebaseUser.photoUrl, 'id': firebaseUser.uid }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SharedPreferences prefs; | |
| prefs = await SharedPreferences.getInstance(); | |
| id = prefs.getString('id') ?? ''; | |
| nickname = prefs.getString('nickname') ?? ''; | |
| aboutMe = prefs.getString('aboutMe') ?? ''; | |
| photoUrl = prefs.getString('photoUrl') ?? ''; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Future uploadFile() async { | |
| String fileName = id; | |
| StorageReference reference = FirebaseStorage.instance.ref().child(fileName); | |
| StorageUploadTask uploadTask = reference.putFile(avatarImageFile); | |
| StorageTaskSnapshot storageTaskSnapshot; | |
| uploadTask.onComplete.then((value) { | |
| if (value.error == null) { | |
| storageTaskSnapshot = value; | |
| storageTaskSnapshot.ref.getDownloadURL().then((downloadUrl) { | |
| photoUrl = downloadUrl; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Container( | |
| child: StreamBuilder( | |
| stream: Firestore.instance.collection('users').limit(_limit).snapshots(), | |
| builder: (context, snapshot) { | |
| if (!snapshot.hasData) { | |
| return Center( | |
| child: CircularProgressIndicator( | |
| valueColor: AlwaysStoppedAnimation<Color>(themeColor), | |
| ), | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Future < Null > handleSignOut() async { | |
| this.setState(() { | |
| isLoading = true; | |
| }); | |
| await FirebaseAuth.instance.signOut(); | |
| await googleSignIn.disconnect(); | |
| await googleSignIn.signOut(); | |
| this.setState(() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| appBar: AppBar( | |
| title: Text( | |
| this.widget.arguments.peerNickname, | |
| style: TextStyle(color: ColorConstants.primaryColor), | |
| ), | |
| centerTitle: true, | |
| ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void _onBackPress() { | |
| _chatProvider.updateDataFirestore( | |
| FirestoreConstants.pathUserCollection, | |
| _currentUserId, | |
| {FirestoreConstants.chattingWith: null}, | |
| ); | |
| Navigator.pop(context); | |
| } | |
| void _getSticker() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| StreamBuilder( | |
| stream: Firestore.instance | |
| .collection('messages') | |
| .document(groupChatId) | |
| .collection(groupChatId) | |
| .orderBy('timestamp', descending: true) | |
| .limit(_limit) | |
| .snapshots(), | |
| builder: (context, snapshot) { | |
| if (!snapshot.hasData) { |