fix example

This commit is contained in:
Salvatore Giordano
2021-02-24 10:48:04 +01:00
parent 950a2347b2
commit 925817383f
2 changed files with 7 additions and 25 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
> The official Flutter core components for Stream Chat, a service for > The official Flutter core components for Stream Chat, a service for
> building chat applications. > building chat applications.
[![Pub](https://img.shields.io/pub/v/stream_chat_flutter.svg)](https://pub.dartlang.org/packages/stream_chat_flutter) [![Pub](https://img.shields.io/pub/v/stream_chat_flutter_core.svg)](https://pub.dartlang.org/packages/stream_chat_flutter_core)
![](https://img.shields.io/badge/platform-flutter%20%7C%20flutter%20web-ff69b4.svg?style=flat-square) ![](https://img.shields.io/badge/platform-flutter%20%7C%20flutter%20web-ff69b4.svg?style=flat-square)
[![Gitter](https://badges.gitter.im/GetStream/stream-chat-flutter.svg)](https://gitter.im/GetStream/stream-chat-flutter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Gitter](https://badges.gitter.im/GetStream/stream-chat-flutter.svg)](https://gitter.im/GetStream/stream-chat-flutter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
![CI](https://github.com/GetStream/stream-chat-flutter/workflows/stream_flutter_workflow/badge.svg?branch=master) ![CI](https://github.com/GetStream/stream-chat-flutter/workflows/stream_flutter_workflow/badge.svg?branch=master)
@@ -5,10 +5,7 @@ import 'package:stream_chat_persistence/stream_chat_persistence.dart';
Future<void> main() async { Future<void> main() async {
/// Create a new instance of [StreamChatClient] passing the apikey obtained from your /// Create a new instance of [StreamChatClient] passing the apikey obtained from your
/// project dashboard. /// project dashboard.
final client = StreamChatClient( final client = StreamChatClient('b67pax5b2wdq');
'b67pax5b2wdq',
logLevel: Level.INFO,
);
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@@ -178,15 +175,6 @@ class _MessageViewState extends State<MessageView> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(
children: [ children: [
StreamBuilder<List<Message>>(
initialData: widget.channel.state.pinnedMessages,
stream: widget.channel.state.pinnedMessagesStream,
builder: (context, snap) {
return Column(
children: snap.data?.map((p) => Text(p.text))?.toList() ?? [],
);
},
),
Expanded( Expanded(
child: ListView.builder( child: ListView.builder(
controller: _scrollController, controller: _scrollController,
@@ -195,17 +183,11 @@ class _MessageViewState extends State<MessageView> {
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
final item = _messages[index]; final item = _messages[index];
if (item.user.id == widget.channel.client.uid) { if (item.user.id == widget.channel.client.uid) {
return GestureDetector( return Align(
onLongPress: () { alignment: Alignment.centerRight,
print('pinning'); child: Padding(
widget.channel.pinMessage(item, 120); padding: const EdgeInsets.all(8.0),
}, child: Text(item.text),
child: Align(
alignment: Alignment.centerRight,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(item.text),
),
), ),
); );
} else { } else {