update tutorials
This commit is contained in:
@@ -46,7 +46,7 @@ linter:
|
||||
- package_prefixed_library_names
|
||||
- prefer_is_not_empty
|
||||
# - prefer_mixin # https://github.com/dart-lang/language/issues/32
|
||||
- public_member_api_docs
|
||||
# - public_member_api_docs
|
||||
- slash_for_doc_comments
|
||||
# - sort_constructors_first
|
||||
# - sort_unnamed_constructors_first
|
||||
|
||||
@@ -2,11 +2,17 @@ import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() async {
|
||||
/// Create a new instance of [StreamChatClient] passing the apikey obtained from your
|
||||
/// project dashboard.
|
||||
final client = StreamChatClient(
|
||||
's2dxdhpxd94g',
|
||||
logLevel: Level.INFO,
|
||||
);
|
||||
|
||||
/// Set the current user. 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.setUser(
|
||||
User(id: 'super-band-9'),
|
||||
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoic3VwZXItYmFuZC05In0.0L6lGoeLwkz0aZRUcpZKsvaXtNEDHBcezVTZ0oPq40A',
|
||||
@@ -20,10 +26,24 @@ void main() async {
|
||||
runApp(MyApp(client, 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 {
|
||||
/// 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;
|
||||
|
||||
/// 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`.
|
||||
MyApp(this.client, this.channel);
|
||||
|
||||
@override
|
||||
@@ -43,7 +63,12 @@ class MyApp extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// 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);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// ignore_for_file: public_member_api_docs
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// ignore_for_file: public_member_api_docs
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// ignore_for_file: public_member_api_docs
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// ignore_for_file: public_member_api_docs
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
@@ -76,7 +77,7 @@ class ChannelListPage extends StatelessWidget {
|
||||
final lastMessage = channel.state.messages.reversed
|
||||
.firstWhere((message) => !message.isDeleted);
|
||||
|
||||
final subtitle = (lastMessage == null ? "nothing yet" : lastMessage.text);
|
||||
final subtitle = (lastMessage == null ? 'nothing yet' : lastMessage.text);
|
||||
final opacity = channel.state.unreadCount > .0 ? 1.0 : 0.5;
|
||||
|
||||
return ListTile(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// ignore_for_file: public_member_api_docs
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// ignore_for_file: public_member_api_docs
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// ignore_for_file: public_member_api_docs
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// This is a basic Flutter widget test.
|
||||
//
|
||||
// To perform an interaction with a widget in your test, use the WidgetTester
|
||||
// utility that Flutter provides. For example, you can send tap and scroll
|
||||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
||||
// tree, read text, and verify that the values of widget properties are correct.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:example/main.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(MyApp());
|
||||
|
||||
// Verify that our counter starts at 0.
|
||||
expect(find.text('0'), findsOneWidget);
|
||||
expect(find.text('1'), findsNothing);
|
||||
|
||||
// Tap the '+' icon and trigger a frame.
|
||||
await tester.tap(find.byIcon(Icons.add));
|
||||
await tester.pump();
|
||||
|
||||
// Verify that our counter has incremented.
|
||||
expect(find.text('0'), findsNothing);
|
||||
expect(find.text('1'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user