* chore: remove examples and tests from analysis exclusion * chore: apply linter fixes to stream_chat_flutter_core/example/main.dart * chore: apply linter fixes to stream_chat_flutter/example/main.dart * chore: apply linter fixes to stream_chat_persistence/example/main.dart * chore: apply linter fixes to stream_chat/example/main.dart * chore: apply linter fixes to stream_chat_flutter/example/split_view.dart * chore: renamte tutorial files per linter * chore: apply linter fixes to tutorial_part_1.dart * chore: apply linter fixes to tutorial_part_2.dart * chore: apply linter fixes to tutorial_part_3.dart * chore: apply linter fixes to tutorial_part_4.dart * chore: apply linter fixes to tutorial_part_5.dart * chore: make a widget const in tutorial_part_5.dart * chore: apply linter fixes to tutorial_part_6.dart * chore: sort and update dependencies in stream_chat_persistence/example/pubspec.yaml * chore: sort and update dependencies in stream_chat_flutter_core/example/pubspec.yaml * chore: sort and update dependencies in stream_chat_flutter/example/pubspec.yaml * chore: sort dependencies in stream_chat_flutter/example/pubspec.yaml * chore: apply linter fixes to channel_test.dart * chore: apply linter fixes to client_test.dart * chore: apply linter fixes to client_test.dart, stream_http_client_test.dart, and token_manager_test.dart * chore: apply linter fixes to filter_test.dart * chore: apply linter fixes to reaction_test.dart * chore: apply linter fixes to chat_persistence_client_test.dart * chore: apply linter fixes to channel_image_test.dart * chore: apply linter fixes to deleted_message_test.dart * chore: apply linter fixes to full_screen_media_test.dart * chore: apply linter fixes to gallery_footer_theme_test.dart * chore: apply linter fixes to gallery_header_theme_test.dart * chore: apply linter fixes to message_text_test.dart * chore: apply linter fixes to reaction_bubble_test.dart * chore: apply linter fixes to system_message_test.dart * chore: apply linter fixes to typing_indicator_test.dart * chore: apply linter fixes to channel_list_core_test.dart * chore: apply linter fixes to channels_bloc_test.dart * chore: apply linter fixes to lazy_load_scroll_view_test.dart * chore: apply linter fixes to channel_matcher.dart * chore: apply linter fixes to message_matcher.dart * chore: apply linter fixes to users_matcher.dart * chore: apply linter fixes to message_list_core_test.dart * chore: apply linter fixes to message_search_bloc_test.dart * chore: apply linter fixes to message_search_list_core_test.dart * chore: apply linter fixes to stream_channel_test.dart * chore: apply linter fixes to stream_chat_core_test.dart * chore: apply linter fixes to user_list_core_test.dart * chore: apply linter fixes to channel_query_dao_test.dart, message_mapper_test.dart, user_mapper_test.dart, and users_bloc_test.dart * chore: apply some missed dartfmt * test: regenerate failinggolden test
110 lines
3.3 KiB
Dart
110 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
|
import 'package:stream_chat_persistence/stream_chat_persistence.dart';
|
|
|
|
/// A chat-persisted StreamChatClient
|
|
final chatPersistentClient = StreamChatPersistenceClient(
|
|
logLevel: Level.INFO,
|
|
);
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
/// Create a new instance of [StreamChatClient] passing the apikey obtained
|
|
/// from your project dashboard.
|
|
final client = StreamChatClient(
|
|
's2dxdhpxd94g',
|
|
logLevel: Level.INFO,
|
|
)..chatPersistenceClient = chatPersistentClient;
|
|
|
|
/// Set the current user and connect the websocket. In a production
|
|
/// scenario, this should be done using a backend to generate a user token
|
|
/// using our server SDK.
|
|
///
|
|
/// Please see the following for more information:
|
|
/// https://getstream.io/chat/docs/ios_user_setup_and_tokens/
|
|
await client.connectUser(
|
|
User(id: 'super-band-9'),
|
|
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoic3VwZXItYmFuZC05In0.'
|
|
'0L6lGoeLwkz0aZRUcpZKsvaXtNEDHBcezVTZ0oPq40A',
|
|
);
|
|
|
|
final channel = client.channel('messaging', id: 'godevs');
|
|
|
|
await channel.watch();
|
|
|
|
runApp(
|
|
MyApp(
|
|
client: client,
|
|
channel: channel,
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Example application using Stream Chat Flutter widgets.
|
|
///
|
|
/// Stream Chat Flutter is a set of Flutter widgets which provide full chat
|
|
/// functionalities for building Flutter applications using Stream. If you'd
|
|
/// prefer using minimal wrapper widgets for your app, please see our other
|
|
/// package, `stream_chat_flutter_core`.
|
|
class MyApp extends StatelessWidget {
|
|
/// Example using Stream's Flutter package.
|
|
///
|
|
/// If you'd prefer using minimal wrapper widgets for your app, please see
|
|
/// our other package, `stream_chat_flutter_core`.
|
|
const MyApp({
|
|
Key? key,
|
|
required this.client,
|
|
required this.channel,
|
|
}) : super(key: key);
|
|
|
|
/// Instance of Stream Client.
|
|
///
|
|
/// Stream's [StreamChatClient] can be used to connect to our servers and
|
|
/// set the default user for the application. Performing these actions
|
|
/// trigger a websocket connection allowing for real-time updates.
|
|
final StreamChatClient client;
|
|
|
|
/// Instance of the Channel
|
|
final Channel channel;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => MaterialApp(
|
|
theme: ThemeData.light(),
|
|
darkTheme: ThemeData.dark(),
|
|
builder: (context, widget) => StreamChat(
|
|
client: client,
|
|
child: widget,
|
|
),
|
|
home: StreamChannel(
|
|
channel: channel,
|
|
child: const ChannelPage(),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// A list of messages sent in the current channel.
|
|
///
|
|
/// This is implemented using [MessageListView], a widget that provides query
|
|
/// functionalities fetching the messages from the api and showing them in a
|
|
/// listView.
|
|
class ChannelPage extends StatelessWidget {
|
|
/// Creates the page that shows the list of messages
|
|
const ChannelPage({
|
|
Key? key,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Scaffold(
|
|
appBar: const ChannelHeader(),
|
|
body: Column(
|
|
children: const <Widget>[
|
|
Expanded(
|
|
child: MessageListView(),
|
|
),
|
|
MessageInput(),
|
|
],
|
|
),
|
|
);
|
|
}
|