From ae50dd2e71745d42b7f21712787bdbd5f6fa8d1f Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Wed, 19 Jan 2022 19:03:09 +0530 Subject: [PATCH 1/7] fix(sample): fix various bugs. Signed-off-by: xsahil03x --- packages/stream_chat_v1/lib/channel_list_page.dart | 10 +++++++++- packages/stream_chat_v1/lib/chat_info_screen.dart | 7 ++++--- .../stream_chat_v1/lib/group_chat_details_screen.dart | 2 +- packages/stream_chat_v1/lib/group_info_screen.dart | 3 ++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/stream_chat_v1/lib/channel_list_page.dart b/packages/stream_chat_v1/lib/channel_list_page.dart index be43bd6..d484307 100644 --- a/packages/stream_chat_v1/lib/channel_list_page.dart +++ b/packages/stream_chat_v1/lib/channel_list_page.dart @@ -40,7 +40,15 @@ class _ChannelListPageState extends State { Positioned( top: -3, right: -16, - child: UnreadIndicator(), + child: StreamBuilder( + stream: + StreamChat.of(context).client.state.unreadChannelsStream, + initialData: 0, + builder: + (BuildContext context, AsyncSnapshot snapshot) { + return Text(snapshot.data.toString()); + }, + ), ), ], ), diff --git a/packages/stream_chat_v1/lib/chat_info_screen.dart b/packages/stream_chat_v1/lib/chat_info_screen.dart index 2ba0789..c6b6a8c 100644 --- a/packages/stream_chat_v1/lib/chat_info_screen.dart +++ b/packages/stream_chat_v1/lib/chat_info_screen.dart @@ -245,12 +245,13 @@ class _ChatInfoScreenState extends State { if (channel.state == null) { await channel.watch(); } - Navigator.pushNamed( + Navigator.pushNamedAndRemoveUntil( context, Routes.CHANNEL_PAGE, + ModalRoute.withName(Routes.CHANNEL_LIST_PAGE), arguments: ChannelPageArgs( - channel: channel, - initialMessage: message, + channel: c, + initialMessage: m, ), ); }, diff --git a/packages/stream_chat_v1/lib/group_chat_details_screen.dart b/packages/stream_chat_v1/lib/group_chat_details_screen.dart index df40cc5..7dec664 100644 --- a/packages/stream_chat_v1/lib/group_chat_details_screen.dart +++ b/packages/stream_chat_v1/lib/group_chat_details_screen.dart @@ -144,7 +144,7 @@ class _GroupChatDetailsScreenState extends State { Navigator.pushNamedAndRemoveUntil( context, Routes.CHANNEL_PAGE, - ModalRoute.withName(Routes.HOME), + ModalRoute.withName(Routes.CHANNEL_LIST_PAGE), arguments: ChannelPageArgs(channel: channel), ); } catch (err) { diff --git a/packages/stream_chat_v1/lib/group_info_screen.dart b/packages/stream_chat_v1/lib/group_info_screen.dart index 6a06e1e..b518163 100644 --- a/packages/stream_chat_v1/lib/group_info_screen.dart +++ b/packages/stream_chat_v1/lib/group_info_screen.dart @@ -534,9 +534,10 @@ class _GroupInfoScreenState extends State { if (channel.state == null) { await channel.watch(); } - Navigator.pushNamed( + Navigator.pushNamedAndRemoveUntil( context, Routes.CHANNEL_PAGE, + ModalRoute.withName(Routes.CHANNEL_LIST_PAGE), arguments: ChannelPageArgs( channel: channel, initialMessage: message, From 13765c217968200acbbdf6e1b0d9d7b350d12391 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 3 Feb 2022 17:19:48 +0100 Subject: [PATCH 2/7] update deps --- packages/stream_chat_v1/lib/channel_list_page.dart | 10 +--------- packages/stream_chat_v1/pubspec.yaml | 4 ++-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/packages/stream_chat_v1/lib/channel_list_page.dart b/packages/stream_chat_v1/lib/channel_list_page.dart index d484307..be43bd6 100644 --- a/packages/stream_chat_v1/lib/channel_list_page.dart +++ b/packages/stream_chat_v1/lib/channel_list_page.dart @@ -40,15 +40,7 @@ class _ChannelListPageState extends State { Positioned( top: -3, right: -16, - child: StreamBuilder( - stream: - StreamChat.of(context).client.state.unreadChannelsStream, - initialData: 0, - builder: - (BuildContext context, AsyncSnapshot snapshot) { - return Text(snapshot.data.toString()); - }, - ), + child: UnreadIndicator(), ), ], ), diff --git a/packages/stream_chat_v1/pubspec.yaml b/packages/stream_chat_v1/pubspec.yaml index 9043349..6733549 100644 --- a/packages/stream_chat_v1/pubspec.yaml +++ b/packages/stream_chat_v1/pubspec.yaml @@ -26,8 +26,8 @@ dependencies: ref: develop path: packages/stream_chat_localizations flutter_local_notifications: ^9.0.0 - flutter_svg: ^0.23.0 - flutter_secure_storage: ^4.2.1 + flutter_svg: ^1.0.3 + flutter_secure_storage: ^5.0.2 yaml: ^3.1.0 uuid: ^3.0.5 streaming_shared_preferences: ^2.0.0 From 8899db862a94684e223807cb78e9da146e513384 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 3 Feb 2022 17:47:57 +0100 Subject: [PATCH 3/7] update android compile sdk --- packages/stream_chat_v1/android/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stream_chat_v1/android/app/build.gradle b/packages/stream_chat_v1/android/app/build.gradle index ce7eeee..147d607 100644 --- a/packages/stream_chat_v1/android/app/build.gradle +++ b/packages/stream_chat_v1/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 30 + compileSdkVersion 31 ndkVersion '21.4.7075529' sourceSets { From 8d66c59a3c3e07873822b773964a071f21dd34e0 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 20 Apr 2022 11:08:27 +0200 Subject: [PATCH 4/7] bump version --- packages/stream_chat_v1/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stream_chat_v1/pubspec.yaml b/packages/stream_chat_v1/pubspec.yaml index 6733549..1585c6b 100644 --- a/packages/stream_chat_v1/pubspec.yaml +++ b/packages/stream_chat_v1/pubspec.yaml @@ -1,7 +1,7 @@ name: example description: A new Flutter project. publish_to: 'none' -version: 1.7.1 +version: 1.8.1 environment: sdk: '>=2.12.0 <3.0.0' From 508063a0c97e709438435ce8489563afbc8b1334 Mon Sep 17 00:00:00 2001 From: Gordon Date: Wed, 20 Apr 2022 11:36:18 +0200 Subject: [PATCH 5/7] docs: update samples and presentation --- README.md | 83 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 60 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 2472b01..763c37c 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,66 @@ -# Flutter samples +# Stream Flutter Samples ![](https://raw.githubusercontent.com/GetStream/flutter-samples/master/images/sdk_hero_v4.png) -**Quick Links** +## 😎 Repo Overview -- [Register](https://getstream.io/chat/trial/) to get an API key for Stream Chat +This repo contains official Stream projects, guides, links to helpful resources, and excellent tutorials and samples developed by the Flutter community. + +#### Quick Links + +- [Register For a Free Account](https://getstream.io/try-for-free/) +- [Stream Flutter YouTube Playlist](https://www.youtube.com/playlist?list=PLNBhvhkAJG6t-BxkRAnSqa67lm5C1mpKk) + +**Chat:** - [Flutter Chat Tutorial](https://getstream.io/chat/flutter/tutorial/) +- [Flutter Chat SDK Repo](https://github.com/GetStream/stream-chat-flutter) +- [Flutter Chat Client Documentation](https://getstream.io/chat/docs/flutter-dart/?language=dart) +- [Flutter Chat UI Documentation and Helpful Guides](https://getstream.io/chat/docs/sdk/flutter/) - [Chat UI Kit](https://getstream.io/chat/ui-kit/) -- [Flutter SDK Repo](https://github.com/GetStream/stream-chat-flutter) +**Feeds:** +- [Flutter Feed Tutorial](https://getstream.io/activity-feeds/sdk/flutter/tutorial/) +- [Flutter Feed SDK Repo](https://github.com/GetStream/stream-feed-flutter) +- [Flutter Feed Client Documentation](https://getstream.io/activity-feeds/docs/flutter-dart/?language=dart) + + + +🔎 Official Samples and Tutorials +------------ + +| 🔮 Official Samples | | +|:-----|---------| +|

Stream Chat Sample Application

A fully fledged messaging application, demoing everything you can do with Stream Chat Flutter, using our UI package.

• Maintained to support the latest version of the SDK
• Combination of pre-made widgets and custom widgets
• Light & dark themes
• Localization
• Multiple users accounts
• Message search and filtering
• Create private and group chats
• View @mentions
• View pinned messages, files, photos and videos
• Base Stream Chat functionality

**[> Source Code](packages/stream_chat_v1)**

| Stream Chat Flutter Sample App | +| ⚙️ Tutorials | | +|

Stream Chat Flutter Core Application

**[> YouTube Tutorial Playlist](https://www.youtube.com/playlist?list=PLNBhvhkAJG6sH7dkmwt4BiCclFkMoXq4r)**

An ongoing, beginner friendly, series, demoing how to use the Stream Chat Flutter Core package for lower level control and customization options.

• Custom UI components
• Lower level client integration
• Light & dark themes
• Multiple users accounts
• Firebase Authentication
• Firebase Cloud Functions to generate user tokens
• Create private chats

**[> Source Code](https://github.com/HayesGordon/chatter)**

| Chatter Application Preview | +|

Instagram Clone

**[> YouTube Tutorial](https://youtu.be/fHRB6KGoaV0)**
**[> Written Tutorial](https://getstream.io/blog/instagram-clone-flutter/)**

A tutorial showing how to use Stream Feed Flutter to create an Instagram clone using activity feeds.

• Instagram-like animations and transitions
• Light & dark themes
• Add and change profile pictures
• Multiple users accounts
• State management with Provider
• Application architecture
• Add photo posts to your own user feed (activities)
• Follow/Unfollow other users' feeds
• Add comments and likes (reactions)

**[> Source Code](https://github.com/GetStream/flutter-instagram-clone)**

| Chatter Application Preview | +|

iMessage Clone

**[> Written Tutorial](https://getstream.io/blog/build-an-imessage-clone-with-streams-flutter-chat-sdk/)**

This tutorial shows how to use Stream Chat Flutter Core to create a basic chat application, styled similar to iMessage.

• Custom chat bubbles with a custom painter
• Core chat components
• Sending attachments
• Chat functionality
• List all channels
**[> Source Code](https://github.com/GetStream/flutter-samples/tree/main/packages/imessage)**

| Chatter Application Preview | +| ⚙️ Codelabs | | +|

Animated Stickers And Reactions With Rive

**[> Codelab](https://getstream.io/codelabs/flutter/flutter-chat-and-rive-animations/)**

Add animated reactions and stickers to your chat application using Rive.

• Rive animations
• Custom attachments
• Custom reactions

**[> Source Code](https://github.com/HayesGordon/stream-chat-flutter-animated-stickers)**

| Animated Reactions/Stickers with Rive | +| | | + +## Chat Guides +See [here](https://getstream.io/chat/docs/sdk/flutter/) for all our chat guides. + +These guides explore our UI components in greater detail and demonstrate how to easily perform a variety of common actions using the Stream Chat Flutter SDK, such as: +- [Adding Push Notifications](https://getstream.io/chat/docs/sdk/flutter/guides/adding_push_notifications_v2/) +- [Adding Localization](https://getstream.io/chat/docs/sdk/flutter/guides/adding_localization/) +- [Adding Custom Attachments - Location Sharing](https://getstream.io/chat/docs/sdk/flutter/guides/adding_custom_attachments/) +- [Token Generation With Firebase Auth and Cloud Functions](https://getstream.io/chat/docs/sdk/flutter/guides/token_generation_with_firebase/) +- [Adding Chat To Video Livestreams](https://getstream.io/chat/docs/sdk/flutter/guides/adding_chat_to_video_livestreams/) +- [Adding Local Data Persistence](https://getstream.io/chat/docs/sdk/flutter/guides/adding_local_data_persistence/) +- [Understanding Filters](https://getstream.io/chat/docs/sdk/flutter/guides/understanding_filters/) +- [End To End Chat Encryption](https://getstream.io/chat/docs/sdk/flutter/guides/end_to_end_chat_encryption/) + +## Chat Tutorials +Chat tutorials that go into greater detail on certain topics: +- [Add Peer-to-Peer Payment Integration With Stream and Rapyd](https://getstream.io/blog/p2p-integration-with-flutter/) +- [Send Voice Messages](https://getstream.io/blog/instantly-send-audio-messages-with-stream-chat-and-flutter/) +- [Location Sharing](https://getstream.io/blog/add-location-sharing-to-a-messaging-app-using-flutter/) ## What is Stream? -Stream allows developers to rapidly deploy scalable feeds and chat messaging with an industry leading 99.999% uptime SLA guarantee. +Stream allows developers to rapidly deploy scalable feeds and chat messaging with an industry-leading 99.999% uptime SLA guarantee. With Stream's chat components, developers quickly add chat to their app for a variety of use-cases: @@ -22,28 +70,17 @@ With Stream's chat components, developers quickly add chat to their app for a va - Messaging style chat like Whatsapp or Facebook's messenger - Commerce chat like Drift or Intercom -## Repo Overview 😎 - -This repo contains projects and samples developed by the team and Stream community. Projects are broke up into directories under the `packages` folder. - -Each project contains a README with build and execution instructions. - -## **Maintained Projects 🚀** -- [Stream Chat v1](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1): a sample app implemented using Stream Chat and Flutter. It is a fully fledged messaging app built using a combination of our pre-made widgets and custom Flutter widgets. -- [Chatter YouTube Series](https://github.com/HayesGordon/chatter): an ongoing, beginner friendly, YouTube video series showing how to use Stream's Flutter packages. -- [iMessage clone](https://github.com/GetStream/flutter-samples/tree/main/packages/imessage): an iMessage clone implemented using Flutter and the `stream_chat_flutter_core` package. - -## **Historic Projects 📕** +## 📕 Historic Projects *These projects are not actively maintained. They were developed using older versions of our packages and Flutter.* - [Stream Chatty](https://github.com/GetStream/flutter-samples/tree/main/packages/chatty) Stream Chatty is a sample chat app made in Flutter using Stream Chat, Firebase, and flutter_bloc. It has full light and dark mode support, real-time chat, and full authentication using Firebase auth. -## Requirements 🛠 +## 🛠 Requirements -Before running this project please ensure Flutter is installed and configured on your machine. If you're new to Flutter, please checkout the [official guide](https://flutter.dev/docs/get-started/install) with installation instructions for your OS. +Before running this project, please ensure Flutter is installed and configured on your machine. If you're new to Flutter, please check out the [official guide](https://flutter.dev/docs/get-started/install) with installation instructions for your OS. -## Contributing +## 📈 Contributing - How can I submit a sample app? - - Apps submissions are always welcomed! 🥳 Open a pr with a proper description and we'll review it as soon as possible -- Spot a bug 🕷 ? - - We welcome code changes that improve the apps or fix a problem. Please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. + - Apps submissions are always welcomed! 🥳 Open a pr with a proper description, and we'll review it as soon as possible +- Spot a bug 🕷? + - We welcome code changes that improve the apps or fix a problem. Please follow all best practices and add tests if applicable before submitting a Pull Request on Github. From 8931c1b49adf241f670030c22fffbb47a3aba296 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Fri, 22 Apr 2022 16:21:33 +0530 Subject: [PATCH 6/7] feat(sample-app): add sentry Signed-off-by: xsahil03x --- .../stream_chat_v1/android/app/build.gradle | 2 +- .../lib/advanced_options_page.dart | 5 +- packages/stream_chat_v1/lib/main.dart | 67 +++++++++++++++++-- packages/stream_chat_v1/pubspec.yaml | 6 +- 4 files changed, 64 insertions(+), 16 deletions(-) diff --git a/packages/stream_chat_v1/android/app/build.gradle b/packages/stream_chat_v1/android/app/build.gradle index 147d607..189df97 100644 --- a/packages/stream_chat_v1/android/app/build.gradle +++ b/packages/stream_chat_v1/android/app/build.gradle @@ -40,7 +40,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.example" - minSdkVersion 21 + minSdkVersion 22 targetSdkVersion 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/packages/stream_chat_v1/lib/advanced_options_page.dart b/packages/stream_chat_v1/lib/advanced_options_page.dart index a42f200..facb9a0 100644 --- a/packages/stream_chat_v1/lib/advanced_options_page.dart +++ b/packages/stream_chat_v1/lib/advanced_options_page.dart @@ -294,10 +294,7 @@ class _AdvancedOptionsPageState extends State { ), ); - final client = StreamChatClient( - apiKey, - logLevel: Level.INFO, - )..chatPersistenceClient = chatPersistentClient; + final client = buildStreamChatClient(apiKey); try { await client.connectUser( diff --git a/packages/stream_chat_v1/lib/main.dart b/packages/stream_chat_v1/lib/main.dart index fc4ed9b..3acb1a9 100644 --- a/packages/stream_chat_v1/lib/main.dart +++ b/packages/stream_chat_v1/lib/main.dart @@ -4,17 +4,16 @@ import 'package:example/choose_user_page.dart'; import 'package:example/home_page.dart'; import 'package:example/localizations.dart'; import 'package:example/splash_screen.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'package:stream_chat_localizations/stream_chat_localizations.dart'; import 'package:stream_chat_persistence/stream_chat_persistence.dart'; import 'package:streaming_shared_preferences/streaming_shared_preferences.dart'; -import 'app_config.dart'; import 'routes/app_routes.dart'; import 'routes/routes.dart'; @@ -23,8 +22,65 @@ final chatPersistentClient = StreamChatPersistenceClient( connectionMode: ConnectionMode.regular, ); +void sampleAppLogHandler(LogRecord record) async { + if (kDebugMode) StreamChatClient.defaultLogHandler(record); + + // report errors to sentry + if (record.error != null || record.stackTrace != null) { + await Sentry.captureException( + record.error, + stackTrace: record.stackTrace, + ); + } +} + +StreamChatClient buildStreamChatClient( + String apiKey, { + Level logLevel = Level.SEVERE, +}) { + return StreamChatClient( + apiKey, + logLevel: logLevel, + logHandlerFunction: sampleAppLogHandler, + )..chatPersistenceClient = chatPersistentClient; +} + void main() async { - runApp(MyApp()); + const sentryDsn = + 'https://6381ef88de4140db8f5e25ab37e0f08c@o1213503.ingest.sentry.io/6352870'; + + /// Captures errors reported by the Flutter framework. + FlutterError.onError = (FlutterErrorDetails details) { + if (kDebugMode) { + // In development mode, simply print to console. + FlutterError.dumpErrorToConsole(details); + } else { + // In production mode, report to the application zone to report to sentry. + Zone.current.handleUncaughtError(details.exception, details.stack!); + } + }; + + Future _reportError(dynamic error, StackTrace stackTrace) async { + // Print the exception to the console. + if (kDebugMode) { + // Print the full stacktrace in debug mode. + print(stackTrace); + return; + } else { + // Send the Exception and Stacktrace to sentry in Production mode. + await Sentry.captureException(error, stackTrace: stackTrace); + } + } + + runZonedGuarded( + () async { + await SentryFlutter.init( + (options) => options.dsn = sentryDsn, + ); + runApp(MyApp()); + }, + _reportError, + ); } class MyApp extends StatefulWidget { @@ -46,10 +102,7 @@ class _MyAppState extends State token = await secureStorage.read(key: kStreamToken); } - final client = StreamChatClient( - apiKey ?? kDefaultStreamApiKey, - logLevel: Level.SEVERE, - )..chatPersistenceClient = chatPersistentClient; + final client = buildStreamChatClient(apiKey ?? kStreamApiKey); if (userId != null && token != null) { await client.connectUser( diff --git a/packages/stream_chat_v1/pubspec.yaml b/packages/stream_chat_v1/pubspec.yaml index 1585c6b..6f9ccbc 100644 --- a/packages/stream_chat_v1/pubspec.yaml +++ b/packages/stream_chat_v1/pubspec.yaml @@ -33,6 +33,7 @@ dependencies: streaming_shared_preferences: ^2.0.0 lottie: ^1.2.1 collection: ^1.15.0 + sentry_flutter: ^6.5.0 dev_dependencies: flutter_launcher_icons: ^0.9.2 @@ -40,10 +41,7 @@ dev_dependencies: dependency_overrides: stream_chat: - git: - url: https://github.com/GetStream/stream-chat-flutter.git - ref: develop - path: packages/stream_chat + path: ../../../stream-chat-flutter/packages/stream_chat stream_chat_flutter_core: git: url: https://github.com/GetStream/stream-chat-flutter.git From dd65347847ccca79a290f3b468a387a25609d6cc Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Fri, 22 Apr 2022 17:23:11 +0530 Subject: [PATCH 7/7] chore(sample-app): revert stream-chat dependency to git Signed-off-by: xsahil03x --- packages/stream_chat_v1/pubspec.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat_v1/pubspec.yaml b/packages/stream_chat_v1/pubspec.yaml index 6f9ccbc..96af0ca 100644 --- a/packages/stream_chat_v1/pubspec.yaml +++ b/packages/stream_chat_v1/pubspec.yaml @@ -41,7 +41,10 @@ dev_dependencies: dependency_overrides: stream_chat: - path: ../../../stream-chat-flutter/packages/stream_chat + git: + url: https://github.com/GetStream/stream-chat-flutter.git + ref: develop + path: packages/stream_chat stream_chat_flutter_core: git: url: https://github.com/GetStream/stream-chat-flutter.git