Code Monkey home page Code Monkey logo

Comments (10)

pricejiang avatar pricejiang commented on July 19, 2024 1

Hi, I am still having this issue. When I click in the textfield, the keyboard pops up and pops down immediately with this error thrown out.

I think managed to solve my problem... The thing is that I wrapped dash_chat under a future builder. When I tap the textfield, it seems that set_state is called and future builder would reload. Then, the scrollcontroller is not attached. The solution is to separate dash chat into another class.

from dash_chat.

LostInDarkMath avatar LostInDarkMath commented on July 19, 2024 1

Finally, I found a solution for my problem. I decide to don't use FutureBuilder at all.

from dash_chat.

fayeed avatar fayeed commented on July 19, 2024

Hi @lchoua Thanks for notifying me about this issue, I have taken a look at the problem, I deploy fix it might take me a couple of days though. If you can fix this feel free to create a pull request.

from dash_chat.

fayeed avatar fayeed commented on July 19, 2024

@lchoua Just fixed this issue try version 1.0.9

from dash_chat.

pricejiang avatar pricejiang commented on July 19, 2024

Hi, I am still having this issue. When I click in the textfield, the keyboard pops up and pops down immediately with this error thrown out.

from dash_chat.

LostInDarkMath avatar LostInDarkMath commented on July 19, 2024

Hi, I just run into the same problem: I use DashChat() inside a FutureBuilder and get this error. Can you please explain how I can solve this issue? I don't exactly now what you mean with "separate dash chat into another class". @pricejiang

from dash_chat.

pricejiang avatar pricejiang commented on July 19, 2024

Hi, I just run into the same problem: I use DashChat() inside a FutureBuilder and get this error. Can you please explain how I can solve this issue? I don't exactly now what you mean with "separate dash chat into another class". @pricejiang

Hi, what I did was wrapped DashChat into a separate StatefulWidget class so it will refresh its own state and will not cause the FutureBuilder to refresh

from dash_chat.

LostInDarkMath avatar LostInDarkMath commented on July 19, 2024

Thank your very much for your fast answer! I'll try 👍

from dash_chat.

LostInDarkMath avatar LostInDarkMath commented on July 19, 2024

@pricejiang Do you have a hint for me how I can set the state of the DashChat wrapper? I don't have any idea how to do this at the moment...

I mean, it has to look something like this:

class Chat extends StatefulWidget {
  final Key _key;
  final Function(ChatMessage) _onSend;
  final Function(ChatUser) _onPressAvatar;
  final Function(ChatUser) _onLongPressAvatar;
  final Function _onLoadEarlier;
  final ChatUser _chatPartner;

  Chat({
    @required Function(ChatMessage) onSend,
    @required Function(ChatUser) onPressAvatar,
    @required Function(ChatUser) onLongPressAvatar,
    @required Function onLoadEarlier,
    @required ChatUser chatPartner,
    Key key,
  })  : assert(onSend != null),
        assert(chatPartner != null),
        assert(onPressAvatar != null),
        assert(onLongPressAvatar != null),
        assert(onLoadEarlier != null),
        _onSend = onSend,
        _chatPartner = chatPartner,
        _onPressAvatar = onPressAvatar,
        _onLongPressAvatar = onLongPressAvatar,
        _onLoadEarlier = onLoadEarlier,
        _key = key,
        super();

  @override
  _ChatState createState() => _ChatState();
}

class _ChatState extends State<Chat> {
  List<ChatMessage> messages = [];

  @override
  Widget build(BuildContext context) {
    return DashChat(
      key: widget._key,
      inverted: false,
      onSend: widget._onSend,
      sendOnEnter: true,
      textInputAction: TextInputAction.send,
      user: widget._chatPartner,
      inputDecoration: InputDecoration.collapsed(
        hintText: 'a hint',
      ),
      messages: messages,
      showUserAvatar: false,
      showAvatarForEveryMessage: false,
      scrollToBottom: true,
      onPressAvatar: widget._onPressAvatar,
      onLongPressAvatar: widget._onLongPressAvatar,
      inputMaxLines: 5,
      messageContainerPadding: EdgeInsets.only(
        left: 5.0,
        right: 5.0,
      ),
      alwaysShowSend: true,
      inputTextStyle: TextStyle(
        fontSize: 16.0,
      ),
      inputContainerStyle: BoxDecoration(
        color: Theme.of(context).backgroundColor,
        border: Border.all(
          width: 0.0,
        ),
      ),
      onQuickReply: (Reply reply) => {print('QuickReply: $reply')},
      onLoadEarlier: widget._onLoadEarlier,
      shouldShowLoadEarlier: false,
      showTraillingBeforeSend: true,
    );
  }
}

I'm stuck here.

from dash_chat.

pricejiang avatar pricejiang commented on July 19, 2024

Not sure about the context of your implementation, but the state of the Chat class should be managed by how your FutureBuilder populate data to it.

from dash_chat.

Related Issues (20)

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.