Code Monkey home page Code Monkey logo

Comments (30)

 avatar commented on July 4, 2024

please help me this!

from flutterchatapptutorial.

MAH0460 avatar MAH0460 commented on July 4, 2024

please help me this!
Please click on get dependencies on the above popup
Make sure to add the latest version of dependencies and multidex in the pubspec.yaml and gradlebuild file from pub.dev .
for any help just comment.
The first error about user. ===>
rename the class and constructor name in user.dart file to AppUser and use AppUser instead of User because User is a firebase method.
and then
return user != null ? AppUser(userId: user.uid) : null;

The second error ===>
In new version of firebase FirebaseUser is replaced only with User. So change the complete function to::::
AppUser _userFromFirebaseUser(User user){
return user != null ? AppUser(userId: user.uid) : null;
}

The third error will be resolved when you do up above.

Error no 4 ====>
In new firebase AuthResults is replaced with UserCredentials. Please do that too.

from flutterchatapptutorial.

MAH0460 avatar MAH0460 commented on July 4, 2024

Your image is not visible.

from flutterchatapptutorial.

 avatar commented on July 4, 2024

Screenshot 2021-01-31 at 2 00 02 PM

from flutterchatapptutorial.

MAH0460 avatar MAH0460 commented on July 4, 2024

The problem is in the main.dart file
Add the code above stateful widget in void main

Screenshot (20)

from flutterchatapptutorial.

 avatar commented on July 4, 2024

Performing hot restart...
Syncing files to device Android SDK built for x86 64...
lib/main.dart:9:9: Error: Getter not found: 'Firebase'.
await Firebase.initializeApp();
^^^^^^^^
Restarted application in 1,261ms.

from flutterchatapptutorial.

MAH0460 avatar MAH0460 commented on July 4, 2024

from flutterchatapptutorial.

 avatar commented on July 4, 2024

Screenshot 2021-02-13 at 9 15 55 PM

from flutterchatapptutorial.

 avatar commented on July 4, 2024

please help me

from flutterchatapptutorial.

MAH0460 avatar MAH0460 commented on July 4, 2024

Please show line number 45 and line number 10

from flutterchatapptutorial.

MAH0460 avatar MAH0460 commented on July 4, 2024

Change the getLoggedInState function as following. It may help

getLoggedInState () async{
await HelperFunctions.getUserLoggedInSharedPreference().then((value){
setState(() {
if(value != null){
setState(() {
userIsLoggedIn = value;
});
}
});
});
}

from flutterchatapptutorial.

 avatar commented on July 4, 2024

Screenshot 2021-02-13 at 9 53 23 PM

from flutterchatapptutorial.

 avatar commented on July 4, 2024

this is also happening since I have updated android
studio

from flutterchatapptutorial.

MAH0460 avatar MAH0460 commented on July 4, 2024

Try to update flutter or reinstall the sdk at C:\src\flutter. This might help.

from flutterchatapptutorial.

MAH0460 avatar MAH0460 commented on July 4, 2024

If the issue is solved please close the topic. Thank you.

from flutterchatapptutorial.

 avatar commented on July 4, 2024

Screenshot 2021-02-16 at 6 38 04 PM

from flutterchatapptutorial.

 avatar commented on July 4, 2024

how do I fix this

from flutterchatapptutorial.

MAH0460 avatar MAH0460 commented on July 4, 2024

Please show me the recent changes which you did before when the error occurred.

from flutterchatapptutorial.

 avatar commented on July 4, 2024

Screenshot 2021-02-16 at 7 34 37 PM

from flutterchatapptutorial.

 avatar commented on July 4, 2024

moved DatabaseMethods from inistate to getuserinfo
and
change snapshot to snapshots

from flutterchatapptutorial.

 avatar commented on July 4, 2024

Screenshot 2021-02-16 at 7 41 25 PM

from flutterchatapptutorial.

MAH0460 avatar MAH0460 commented on July 4, 2024

What's your purpose of doing this? My code is working fine when database method is in initState method. And please show the database method to getChatRoom

from flutterchatapptutorial.

 avatar commented on July 4, 2024

it is not showing data once it is loaded , in the chatroomTile

from flutterchatapptutorial.

 avatar commented on July 4, 2024

What's your purpose of doing this? My code is working fine when database method is in initState method. And please show the database method to getChatRoom

Screenshot 2021-02-16 at 8 11 19 PM

from flutterchatapptutorial.

MAH0460 avatar MAH0460 commented on July 4, 2024

Write a mail to me. I'll share the code. Check for mail in my github ID. Else I'll share the solution code tomorrow.

from flutterchatapptutorial.

 avatar commented on July 4, 2024

plz share here only.

from flutterchatapptutorial.

MAH0460 avatar MAH0460 commented on July 4, 2024

this is the complete.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:ourchat/helper/helperfunctions.dart';
import 'package:ourchat/services/database.dart';

class ConversationScreen extends StatefulWidget {
final String chatRoomId;
final String thisUserName;
ConversationScreen(this.chatRoomId, this.thisUserName);

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

class _ConversationScreenState extends State {
String _x;
DatabaseMethods databaseMethods = new DatabaseMethods();
TextEditingController messageController = new TextEditingController();

Stream chatMessageStream;

Widget chatMessageList(){
return StreamBuilder(
stream: chatMessageStream,
builder: (context, snapshot) {
return snapshot.hasData ?Container(
margin: EdgeInsets.only(bottom: 80),
child: ListView.builder(
reverse: true,
itemCount: snapshot.data.docs.length,
itemBuilder: (context, index){
return MessageTile(snapshot.data.docs[index].data()["message"],
snapshot.data.docs[index].data()["sendBy"] == _x,
snapshot.data.docs[index].data()["time2"]);
}),
) : Container(
child: Center(child: CircularProgressIndicator()),
);
},
);
}

sendMessage(){
if(messageController.text.isNotEmpty){
Map<String, dynamic>messageMap = {
"message" : messageController.text,
"sendBy" : _x,
"time" : DateTime.now().microsecondsSinceEpoch,
"time2" : DateTime.now().toLocal().toString().substring(5, 16)
};
databaseMethods.addConversationMessages(widget.chatRoomId, messageMap);
messageController.text = "";
}
}
void initState(){
getUserName();
databaseMethods.getConversationMessages(widget.chatRoomId).then((value){

  setState(() {
    chatMessageStream = value;
  });
});
super.initState();

}

@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: Row(
children: [Container(
margin: EdgeInsets.only(left: 20, top: 5, bottom: 5),
padding: EdgeInsets.all(10),
width: 36,
height: 36,
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(30),

        ),
      ),
      ],
    ),
    title: Text(widget.thisUserName, style: TextStyle(
      fontFamily: 'Dancing',
      fontSize: 25,
      fontWeight: FontWeight.bold,

    ),),
  ),
  body :Container(
    child: Stack(
      children: [
        chatMessageList(),
        Container(
          alignment: Alignment.bottomCenter,
          child: Container(
            color: Color(0x54FFFFFF),
            padding: EdgeInsets.symmetric(horizontal: 24, vertical: 16),
            child: Row(
              children: [
                Expanded(
                  child: TextField(
                    controller: messageController,
                    style: TextStyle(
                      color: Colors.white,
                    ),
                    decoration: InputDecoration(
                      hintText: "Message...",
                      hintStyle: TextStyle(
                        color: Colors.white54,
                      ),
                      border: InputBorder.none,
                    ),
                  ),
                ),
                GestureDetector(
                  onTap: (){
                    sendMessage();
                  },
                  child: Container(
                      height: 40,
                      width: 40,
                      decoration: BoxDecoration(
                          gradient: LinearGradient(
                            colors: [
                              const Color(0x36FFFFFF),
                              const Color(0x0FFFFFFF),
                            ],
                          ),
                          borderRadius: BorderRadius.circular(40)
                      ),
                      padding: EdgeInsets.all(12),
                      child: Image.asset("assets/images/send.png")),
                )
              ],
            ),
          ),
        ),

      ],
    ),
  )
);

}

getUserName() async{
_x = await HelperFunctions.getUsernameSharedPreference();
}
}

class MessageTile extends StatelessWidget {
final String message;
final bool isSendByMe;
final String tim;
MessageTile(this.message , this.isSendByMe, this.tim);

@OverRide
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(left: isSendByMe ? 60: 12,right: isSendByMe ? 24 : 100),
margin: EdgeInsets.symmetric(vertical: 4),
width: MediaQuery.of(context).size.width,
alignment: isSendByMe ? Alignment.centerRight : Alignment.centerLeft,
child: Column(
children: [
Container(
margin: EdgeInsets.symmetric(vertical: 4),
padding: EdgeInsets.symmetric(horizontal: 24,vertical: 12),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: isSendByMe ? [
const Color(0xff007EF4),
const Color(0xff2A75BC)
]
: [
const Color(0x1AFFFFFF),
const Color(0x1AFFFFFF)
]

          ),
          borderRadius: isSendByMe ?
              BorderRadius.only(
                topLeft: Radius.circular(23),
                topRight: Radius.circular(23),
                bottomLeft: Radius.circular(23)
              )
              :
              BorderRadius.only(
                topLeft: Radius.circular(23),
                topRight: Radius.circular(23),
                bottomRight: Radius.circular(23)
              )
        ),
        child: Text(message, style: TextStyle(
          color: Colors.white,
          fontSize: 16,
        ),
        ),
      ),
      Container(
        child: Text(tim,textAlign: TextAlign.right, style: TextStyle(
          color: Colors.white,
          fontSize: 10
        ),),
      ),
    ],
  ),
);

}
}

from flutterchatapptutorial.

 avatar commented on July 4, 2024

Screenshot 2021-02-18 at 12 22 35 AM

from flutterchatapptutorial.

 avatar commented on July 4, 2024

I am not able to get this what is on that emulator screen

from flutterchatapptutorial.

MAH0460 avatar MAH0460 commented on July 4, 2024

This is the home screen, since I have shared the complete conversation screen code, please complete the video tutorial, you will get what it is.

from flutterchatapptutorial.

Related Issues (15)

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.