Created
May 24, 2021 13:25
-
-
Save pinkeshdarji/e71372475c04eacb1935e1119669d245 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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