|
1 | | -# TalkJS |
| 1 | +# TalkJS Flutter SDK |
2 | 2 |
|
3 | | -Flutter SDK for [TalkJS](https://talkjs.com) |
| 3 | +Official TalkJS SDK for Flutter |
| 4 | + |
| 5 | +**What is TalkJS?** |
| 6 | + |
| 7 | +TalkJS lets you add user-to-user chat to your marketplace, on-demand app, or |
| 8 | +social platform. |
| 9 | +For more information, visit |
| 10 | +[talkjs.com](https://talkjs.com/?ref=jssdk-npm-readme). |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +Don't hesitate to |
| 15 | +[let us know](https://talkjs.com/?chat) |
| 16 | +if you have any questions about TalkJS. |
4 | 17 |
|
5 | 18 | ## Requirements |
6 | 19 |
|
7 | | -- Dart sdk: ">=2.12.0 <3.0.0" |
8 | | -- Flutter: ">=1.17.0" |
| 20 | +- Dart sdk: ">=2.15.0 <3.0.0" |
| 21 | +- Flutter: ">=2.8.1" |
9 | 22 | - Android: `minSDKVersion 19` |
10 | 23 |
|
11 | 24 | ## Installation |
12 | 25 |
|
13 | | -Assumption: You have an existing Flutter Project. You can follow this [guide](https://flutter.dev/docs/get-started/test-drive#create-app) |
14 | | -on how to create a new Flutter Project. |
15 | | - |
16 | | -First, clone this repository on your computer. |
17 | | -```sh |
18 | | -git clone https://github.com/talkjs/flutter-sdk-victor.git |
19 | | -``` |
20 | | - |
21 | | -To add the package as a dependency, edit the dependencies section of |
22 | | -your project's **pubspec.yaml** file in your Flutter project as follows: |
| 26 | +Edit the dependencies section of your project's `pubspec.yaml` file in your |
| 27 | +Flutter project as follows: |
23 | 28 |
|
24 | 29 | ```yaml |
25 | 30 | dependencies: |
26 | | - talkjs: |
27 | | - path: {path to directory containing this repository}/flutter-sdk-victor/talkjs |
| 31 | + talkjs_flutter: ^0.1.0 |
28 | 32 | ``` |
29 | 33 |
|
30 | | -The path specified should be an absolute path from the root directory of |
31 | | -your system. |
32 | | -
|
33 | | -Run the command: ```flutter pub get``` on the command line or through |
34 | | -Android Studio's **Get dependencies** button. |
35 | | - |
36 | | -To debug on Android, put this line in the `android/app/src/main/AndroidManifest.xml` as a property of the `<application` tag: |
| 34 | +Run the command: `flutter pub get` on the command line or through Android |
| 35 | +Studio's **Get dependencies** button. |
37 | 36 |
|
38 | | -```xml |
39 | | - android:usesCleartextTraffic="true" |
40 | | -``` |
41 | 37 |
|
42 | | -## Getting Started |
| 38 | +## Usage |
43 | 39 |
|
44 | | -If you used the [guide](https://flutter.dev/docs/get-started/test-drive#create-app) |
45 | | -mentioned above to create a new Flutter project, replace everything in |
46 | | -**lib/main.dart** with the following code: |
| 40 | +Import TalkJS in your project source files. |
47 | 41 |
|
48 | 42 | ```dart |
49 | | -import 'package:flutter/material.dart'; |
50 | | -import 'package:talkjs/talkjs.dart'; |
51 | | -
|
52 | | -void main() { |
53 | | - runApp(MyApp()); |
54 | | -} |
55 | | -
|
56 | | -class MyApp extends StatelessWidget { |
57 | | - @override |
58 | | - Widget build(BuildContext context) { |
59 | | - return MaterialApp( |
60 | | - title: 'TalkJS Demo', |
61 | | - home: Scaffold( |
62 | | - body: initChat() |
63 | | - ) |
64 | | - ); |
65 | | - } |
66 | | -
|
67 | | - Widget initChat() { |
68 | | - final me = User(id: '123456', name: 'Alice'); |
69 | | - final other = User(id: '654321', name: 'Sebastian'); |
70 | | -
|
71 | | - final session = Session(appId: 'YOUR_APP_ID', me: me); |
72 | | - final conversation = session.getOrCreateConversation( |
73 | | - Talk.oneOnOneId(me.id, other.id) |
74 | | - ); |
75 | | -
|
76 | | - conversation.setParticipant(me); |
77 | | - conversation.setParticipant(other); |
78 | | -
|
79 | | - final chatBox = session.createChatbox(conversation); |
80 | | - return chatBox.mount(); |
81 | | - } |
82 | | -} |
| 43 | +import 'package:talkjs_flutter/talkjs.dart'; |
83 | 44 | ``` |
84 | 45 |
|
85 | | -Replace ```YOUR_APP_ID``` with the App ID on the TalkJS [Dashboard](https://talkjs.com/dashboard/login.) |
86 | | - |
87 | | -For users with an existing Flutter project, you can use the ```Widget``` returned |
88 | | -by the ```initChat``` function in the example above as part of an existing |
89 | | -```Widget``` definition or a navigation route |
90 | | - |
91 | | -## Documentation |
| 46 | +Then follow our |
| 47 | +[Flutter guide](https://talkjs.com/docs/Getting_Started/Frameworks/Flutter/) |
| 48 | +to start using TalkJS in your project. |
| 49 | + |
| 50 | +## TalkJS is fully forward compatible |
| 51 | +We promise to never break API compatibility. |
| 52 | +We may at times deprecate methods or fields, but we will never remove them. |
| 53 | +If something that used to work stops working, then that's a bug. |
| 54 | +Please [report it](https://talkjs.com/?chat) and we'll fix it asap. |
| 55 | + |
| 56 | +The package is being released in a beta state. |
| 57 | +The reason for this is that there are things that one can do with the TalkJS |
| 58 | +JavaScript SDK that aren't possible with the Flutter SDK. |
| 59 | +We will release v1.0.0 of this package once the two SDKs are similar in terms |
| 60 | +of features. |
| 61 | +This however does not take away from our commitment to always maintain backward |
| 62 | +compatibility. |
| 63 | +So you can be assured that the package is stable for production use. |
92 | 64 |
|
93 | | -The SDK API reference can be found in **doc/api**. |
0 commit comments