ult_flutter_ui 0.1.1
ult_flutter_ui: ^0.1.1 copied to clipboard
A Flutter package for building beautiful chat UIs with support for text, images, voice messages, and more.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:ult_flutter_ui/ult_flutter_ui.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Chat UI Example',
theme: ThemeData(
primarySwatch: Colors.blue,
useMaterial3: true,
),
home: const ChatScreen(),
);
}
}
class ChatScreen extends StatelessWidget {
const ChatScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final messages = [
Message(
id: '1',
senderId: 'user1',
text: 'Hello! How are you?',
timestamp: DateTime.now().subtract(const Duration(minutes: 5)),
status: MessageStatus.read,
),
Message(
id: '2',
senderId: 'user2',
text: 'Hi there! I\'m doing great, thanks for asking!',
timestamp: DateTime.now().subtract(const Duration(minutes: 4)),
status: MessageStatus.delivered,
reactions: [
Reaction(emoji: '👍', userId: 'user1', timestamp: DateTime.now()),
],
),
Message(
id: '3',
senderId: 'user1',
text: 'That\'s wonderful to hear!',
timestamp: DateTime.now().subtract(const Duration(minutes: 3)),
status: MessageStatus.sent,
replyToId: '2',
),
Message(
id: '4',
senderId: 'user2',
text: 'Image',
timestamp: DateTime.now().subtract(const Duration(minutes: 2)),
type: MessageType.image,
mediaUrl: 'https://picsum.photos/200/300',
),
Message(
id: '5',
senderId: 'user1',
text: 'Voice message',
timestamp: DateTime.now().subtract(const Duration(minutes: 1)),
type: MessageType.voice,
voiceDuration: 30,
),
];
return Scaffold(
appBar: AppBar(
title: const Text('Chat UI Example'),
),
body: ChatView(
messages: messages,
currentUserId: 'user1',
showUserAvatars: true,
showUserNames: true,
primaryColor: Colors.blue,
secondaryColor: Colors.grey[200],
messageTextStyle: const TextStyle(fontSize: 16),
messageSpacing: 8.0,
messagePadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
messageBorderRadius: BorderRadius.circular(20),
quickReplies: [
'Yes, I agree!',
'No, I disagree',
'Maybe later',
'Let me think about it',
],
onQuickReplySelected: (reply) {
print('Selected quick reply: $reply');
},
),
);
}
}