add multiplr_conversation example

This commit is contained in:
Salvatore Giordano
2020-02-24 16:46:05 +01:00
parent d3b6a7e5e5
commit e0e36f50cc
7 changed files with 139 additions and 161 deletions
+27 -31
View File
@@ -9,27 +9,21 @@ void main() async {
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoid2lsZC1icmVlemUtNyJ9.VM2EX1EXOfgqa-bTH_3JzeY0T99ngWzWahSauP3dBMo',
);
runApp(StreamChat(
client: client,
child: MyApp(),
));
}
final channelClient = client.channel('messaging', id: 'godevs');
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
channelClient.watch();
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.blue,
runApp(
StreamChat(
client: client,
child: MaterialApp(
home: StreamChat(
client: client,
child: ChannelListPage(),
),
),
home: ChannelListPage(),
);
}
),
);
}
class ChannelListPage extends StatelessWidget {
@@ -48,7 +42,10 @@ class ChannelListPage extends StatelessWidget {
),
onChannelTap: (channelClient) {
Navigator.push(context, MaterialPageRoute(builder: (context) {
return ChannelPage(channelClient);
return StreamChannel(
child: ChannelPage(),
channelClient: channelClient,
);
}));
},
),
@@ -57,21 +54,20 @@ class ChannelListPage extends StatelessWidget {
}
class ChannelPage extends StatelessWidget {
ChannelPage(this.channelClient);
final ChannelClient channelClient;
const ChannelPage({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return StreamChannel(
channelClient: channelClient,
child: Scaffold(
body: Column(
children: <Widget>[
Expanded(child: MessageListView()),
MessageInput(),
],
),
return Scaffold(
body: Column(
children: <Widget>[
Expanded(
child: MessageListView(),
),
MessageInput(),
],
),
);
}
+21 -10
View File
@@ -19,18 +19,29 @@ void main() async {
client: client,
child: StreamChannel(
channelClient: channelClient,
child: Scaffold(
body: Column(
children: <Widget>[
Expanded(
child: MessageListView(),
),
MessageInput(),
],
),
),
child: ChannelPage(),
),
),
),
);
}
class ChannelPage extends StatelessWidget {
const ChannelPage({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: <Widget>[
Expanded(
child: MessageListView(),
),
MessageInput(),
],
),
);
}
}
-29
View File
@@ -1,29 +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:example/single_conversation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.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);
});
}