Skip to content

Instantly share code, notes, and snippets.

@pinkeshdarji
Created May 24, 2021 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinkeshdarji/e71372475c04eacb1935e1119669d245 to your computer and use it in GitHub Desktop.
Save pinkeshdarji/e71372475c04eacb1935e1119669d245 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:flutter_desktop_chat_app/responsive_builder.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
//Before
void main() {
runApp(MyApp());
}
//----------------------------
//After
Future<void> main() async {
//Step 1
final client = StreamChatClient(
'YOUR-KEY',
logLevel: Level._INFO_,
);
//Step 2
await client.connectUser(
User(
id: 'Harry',
extraData: {
'image': 'https://picsum.photos/id/1005/200/300',
},
),
client.devToken('Harry'),
);
runApp(MyApp(
client: client,
));
}
class MyApp extends StatelessWidget {
// This widget is the root of your application. const MyApp({Key key, this.client}) : super(key: key); final StreamChatClient client;
@override
Widget build(BuildContext context) {
// Step 3
return StreamChat(
client: client,
child: MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors._blue_,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment