Monday, 22 March 2021

How to send multiline string from graphQL from flutter?

I am trying put multiline support in one of the comment section of app and it is not accepting it.

the input which i put is

Hi
Hello
Hello

and it is showing this error

this is the error i am getting while putting the above input in the textfield

And this is the code i am writing for the inputfield

             ListTile(
                leading: CircleAvatar(
                  backgroundImage: AssetImage(UIData.pkImage),
                ),
                title:  Container(
                  constraints: BoxConstraints(
                    maxHeight: double.infinity,
                    minHeight: 20,
                  ),
                child: TextField(
                  keyboardType: TextInputType.multiline,
                  minLines: 1,//Normal textInputField will be displayed
                  maxLines: 10,// when user presses enter it will adapt to it
                  decoration: InputDecoration(
                      suffix: IconButton(
                        color: Colors.grey,
                        icon: Icon(Icons.send),
                        onPressed: () {
                          createComment();
                        },
                      ),
                      hintText: 'Leave a Comment....',
                      border: OutlineInputBorder(
                          borderRadius: BorderRadius.circular(20.0),
                          borderSide: BorderSide(color: Colors.teal))),
                  controller: commentController,
                ),
                ),
              ),

The problem is with updating the graphQL query and initializing it with String block

String createComments(String postId, var text) {
    return """
mutation{
  createComment(postId: "$postId", 
  data:{
    text: ""$text"",
  }
  ){
    _id
  }
}
"""
;
  }
              


from How to send multiline string from graphQL from flutter?

No comments:

Post a Comment