Skip to content

ojacquemart/Flutchat

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flutchat

This sample is to describe method channel feature in practical aspect. (Complete steps in this blog) We will implement third party dependency provided by TokBox sdk and integrate it along with flutter. The main agenda for method channel is to use platform specific APIs in flutter.

Getting Started

Android

Requirements

  • You need to replace you api key, session id and token with yours here which you can get from OpenTok dashboard project section

Implementation

  • To integrate platform channel in android we need to initiate MehtodChannel in onCreate method in LauncherActivity (Here we will use FirstActivity as Launcher).
        MethodChannel(flutterView, "channel_id")
                .setMethodCallHandler { methodCall, result ->
                    methodCall.method?.let {
                        if (it.contentEquals("method")) {
                          // use result object to pass success or error event to main.dart
                          // the datatype of result will be MethodChannel.Result
                        }
                    }
                }

  • Then we need to invoke method from method channel from main.dart on respective events using following code snippet.
var output = await platform.invokeMethod("method");

Here output variable will get output of method call. It will wait for method execution.

  • To get acomplish method invocation call success or error method from MethodChannel.Result object which we retrive during method channel initialization.

  • We can get output value using result object which we get from MethodCallHandler provided in MethodChannel initialization in Launcher Activity.

result.success(any object);

For more information regarding platform channel refer online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

More reference

About

Flutchat - integration of tokbox native SDK within flutter app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 65.5%
  • Swift 20.6%
  • Dart 10.0%
  • Shell 2.8%
  • Other 1.1%