Comments (5)
Can you provide some code and also which version of dash_chat
, flutter version you are using so that I could investigate the problem.
from dash_chat.
Thanks for your feedback.
This is the code I added to my pubspec.yaml file:
dependencies:
dash_chat: ^1.0.4
While this code was what I added to my main.dart file.
import 'dart:async';
import 'package:dash_chat/dash_chat.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final GlobalKey<DashChatState> _chatViewKey = GlobalKey<DashChatState>();
final ChatUser user = ChatUser(
name: "Fayeed",
uid: "123456789",
avatar: "https://www.wrappixel.com/ampleadmin/assets/images/users/4.jpg",
);
final ChatUser otherUser = ChatUser(
name: "Mrfatty",
uid: "25649654",
avatar: "",
);
List<ChatMessage> messages = List<ChatMessage>();
var m = List<ChatMessage>();
var i = 0;
@override
void initState() {
m.addAll([
ChatMessage(text: "Hi", user: otherUser, createdAt: DateTime.now()),
ChatMessage(
text: "How are you?",
user: otherUser,
createdAt: DateTime.now(),
quickReplies: QuickReplies(
values: <Reply>[
Reply(
title: "Great, What about you",
value: "Great, What about you",
),
Reply(
title: "I am good, How are you",
value: "I am good, How are you",
),
],
),
),
ChatMessage(
text: "I am fine",
user: otherUser,
createdAt: DateTime.now(),
quickReplies: QuickReplies(
values: <Reply>[
Reply(
title: "Where are you travelling too",
value: "Where are you travelling too",
),
Reply(
title: "When do you want to meet",
value: "When do you want to meet",
),
],
),
),
ChatMessage(
text: "Paris",
user: otherUser,
createdAt: DateTime.now(),
quickReplies: QuickReplies(
values: <Reply>[
Reply(
title: "Can you send a pic later",
value: "Can you send a pic later",
),
Reply(
title: "Send me pic of Eiffel tower",
value: "Send me pic of Eiffel tower",
),
],
),
),
ChatMessage(
text: "",
image:
"https://amp.insider.com/images/58d919eaf2d0331b008b4bbd-750-562.jpg",
user: otherUser,
createdAt: DateTime.now(),
quickReplies: QuickReplies(
values: <Reply>[
Reply(
title: "Looks awesome",
value: "Looks awesome",
),
Reply(
title: "Cool",
value: "Cool",
),
Reply(
title: "Wow 😲",
value: "Wow 😲",
),
],
),
),
ChatMessage(
text: "Message you in a bit",
user: otherUser,
createdAt: DateTime.now(),
quickReplies: QuickReplies(
values: <Reply>[
Reply(
title: "I will Message you later",
value: "I will Message you later",
),
Reply(
title: "Maybe not.",
value: "Maybe not.",
),
Reply(
title: "Meet me at my place",
value: "Meet me at my place",
),
Reply(
title: "What!!",
value: "What!!",
),
],
),
)
]);
super.initState();
}
void systemMessage() {
Timer(Duration(milliseconds: 300), () {
if (i < 6) {
setState(() {
messages = [...messages, m[i]];
});
i++;
}
Timer(Duration(milliseconds: 300), () {
_chatViewKey.currentState.scrollController
..animateTo(
_chatViewKey.currentState.scrollController.position.maxScrollExtent,
curve: Curves.easeOut,
duration: const Duration(milliseconds: 300),
);
});
});
}
void onSend(ChatMessage message) {
setState(() {
messages = [...messages, message];
print(messages.length);
});
if (i == 0) {
systemMessage();
Timer(Duration(milliseconds: 600), () {
systemMessage();
});
} else {
systemMessage();
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Chat App"),
),
body: DashChat(
key: _chatViewKey,
inverted: false,
onSend: onSend,
user: user,
inputDecoration:
InputDecoration.collapsed(hintText: "Add message here..."),
dateFormat: DateFormat('yyyy-MMM-dd'),
timeFormat: DateFormat('HH:mm'),
messages: messages,
showUserAvatar: false,
showAvatarForEveryMessage: false,
onPressAvatar: (ChatUser user) {
print("OnPressAvatar: ${user.name}");
},
onLongPressAvatar: (ChatUser user) {
print("OnLongPressAvatar: ${user.name}");
},
inputMaxLines: 5,
messageContainerPadding: EdgeInsets.only(left: 5.0, right: 5.0),
alwaysShowSend: true,
inputTextStyle: TextStyle(fontSize: 16.0),
inputContainerStyle: BoxDecoration(
border: Border.all(width: 0.0),
color: Colors.white,
),
onQuickReply: (Reply reply) {
setState(() {
messages.add(ChatMessage(
text: reply.value, createdAt: DateTime.now(), user: user));
messages = [...messages];
});
Timer(Duration(milliseconds: 300), () {
_chatViewKey.currentState.scrollController
..animateTo(
_chatViewKey
.currentState.scrollController.position.maxScrollExtent,
curve: Curves.easeOut,
duration: const Duration(milliseconds: 300),
);
if (i == 0) {
systemMessage();
Timer(Duration(milliseconds: 600), () {
systemMessage();
});
} else {
systemMessage();
}
});
},
onLoadEarlier: () {
print("laoding...");
},
shouldShowLoadEarlier: true,
showTraillingBeforeSend: true,
trailing: <Widget>[
IconButton(
icon: Icon(Icons.photo),
onPressed: () {
print("object");
},
)
],
),
);
}
}
from dash_chat.
Hey, I don't think this is a problem with the package as I tried reproducing it but everything seems fine. What steps did you take that leads to this error. Are you running the example provided in the package if so there's no need to add dash_chat
in dependencies
from dash_chat.
Thanks for your feedback.
This is the link to my chatbot repository https://github.com/Wizpna/chat_bot
When I run the project, I receive his error message:
Compiler message:
file:///C:/flutter/.pub-cache/hosted/pub.flutter-io.cn/dash_chat-1.0.4/lib/src/chat_input_toolbar.dart:97:21: Error: No named parameter with the name 'showCursor'.
showCursor: showInputCursor,
^^^^^^^^^^
file:///C:/flutter/packages/flutter/lib/src/material/text_field.dart:134:9: Context: Found this candidate, but the arguments don't match.
const TextField({
^
file:///C:/flutter/.pub-cache/hosted/pub.flutter-io.cn/dash_chat-1.0.4/lib/src/widgets/message_container.dart:62:42: Error: The method 'copyWith' isn't defined for the class 'BoxDecoration'.
- 'BoxDecoration' is from 'package:flutter/src/painting/box_decoration.dart' ('file:///C:/flutter/packages/flutter/lib/src/painting/box_decoration.dart').
Try correcting the name to the name of an existing method, or defining a method named 'copyWith'.
? messageContainerDecoration.copyWith(
^^^^^^^^
Compiler failed on D:\chat_bot\lib\main.dart
FAILURE: Build failed with an exception.
-
Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 648 -
What went wrong:
Execution failed for task ':app:compileflutterBuildDebugandroid-arm'.
Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1
-
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. -
Get more help at https://help.gradle.org
BUILD FAILED in 38s
Finished with error: Gradle task assembleDebug failed with exit code 1
You can download the repository and run the project, you will get the same error message.
from dash_chat.
Hey just checked you repository and everything works fine. I think this is something to with your flutter installation. Anyways, since this is not related to this package I am going to close this issue now.
from dash_chat.
Related Issues (20)
- [Bug] Old Chat messages are not aligned with sender to the right HOT 1
- [Question] Does this have null safety? HOT 5
- [Question] Why is it necessary for scrollNotificationFunc to always return true?
- 1.1.16 cannot show emojis HOT 4
- how to use flutter dash_chat with dialogflow?
- why dash_chat support 3 Quick Replies limited at 3? in flutter any idea
- how i use flutter_dialogflow with dashchat to my app flutter
- Can't open chat emoji dash_chat: ^1.1.16 HOT 5
- does the package support sending videos and files ?
- [Feature request] Your title
- [Question] about messageTextBuilder HOT 1
- does 2.0 release? HOT 5
- [Bug] default DateBuilder is wrong when scrolling HOT 1
- [Feature request] ListView.custom to prevent widgets from rebuilding
- [Question] Is it possible to send a new message programmatically?
- How to show sender name or auth anme in massage box list? and also emoji are not working in chat.
- [Feature request] Voice
- Invalid image data
- Null check operator used on a null value
- padding between messages
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dash_chat.