Home
/ Blog /
Video Calling Application in Flutter using 100ms PrebuiltJanuary 2, 20248 min read
Share
Video calls have changed the way we work, learn, and even see a doctor. But behind the scenes, making video calls work well is actually pretty hard. It's like trying to make sure the picture and sound are perfect for everyone, no matter how fast their internet is or what device they're using. And if that's not tricky enough, adding things like chat and synchronized actions feels like too much of handling when you just want to ship faster. If you've ever felt the struggle, don't worry – a lot of us do.
That's why, Drum rolls, please! 🥁 At 100ms, we've developed an SDK with a fully equipped, configurable, and customizable Prebuilt UI support. It's presented as the 100ms Prebuilt Flutter component from the HMSRoomKit
package. With just a few simple steps, you can add a video widget by just adding necessary dependencies, and presto! We've handled everything, from initiating calls to crafting the user interface – making integration a breeze. Now, isn't that exciting?! 🎉
In this article on 100ms Flutter room kit integration assumes a familiarity with Dart and Flutter.
Understanding what you're adding to your app is crucial. Here's a quick rundown of key points about 100ms Prebuilt before you dive into integrating it:
HMSRoomKit
.Currently, 100ms Prebuilt offers a single powerful widget for end-to-end meeting flow, going forward we will be exposing individual components from the package, so don’t forget to Watch and Star the Github repo to stay updated.
We will create a simple video calling and streaming application using HMSRoomKit
package.
Set up a template - A template governs what features your Prebuilt has and how its Prebuilt UI functions. Head over to 100ms dashboard to create a template.
Create a room - A default room gets created for any template created using the 100ms dashboard. Create more rooms under the same template programmatically using the create room API.
Create and get room codes - Room code represents a unique room_id and role combination; room codes can help create room links or power authentication when joining a room. Get room codes for each role
Add the hms_room_kit
package under dependencies in your Flutter project’s puspec.yaml
file.
dependencies:
flutter:
sdk: flutter
# Replace `1.0,8` with whatever is the latest version
hms_room_kit: ^1.0.8
To know more about the package, check out the Flutter repo here.
HMSPrebuilt
Now, simply place the HMSPrebuilt
widget wherever you need it. For instance, in this example, a button labeled "Join" triggers navigation to the meeting UI upon clicking. You’ll notice that joining a room requires a room code which is unique to each role in your template.
Scaffold(
body: Center(
child: ElevatedButton(
style: ButtonStyle(
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
))),
onPressed: () async => {
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const HMSPrebuilt(roomCode: "Enter your room code here")
),
),
},
child: const Padding(
padding: EdgeInsets.symmetric(vertical: 20, horizontal: 20),
child: Text(
'Join',
style: TextStyle(fontSize: 20),
),
),
),
),
);
android/app/build.gradle
file (inside "defaultConfig"), update the minSdkVersion
to 21. ...
defaultConfig {
...
minSdkVersion 21
...
}
...
For iOS, in ios/Podfile
add the target platform version:
platform :ios, '12.0'
And we’re done! Time to run the application.
Add the below code in android/app/src/main/kotlin/live/hms/flutter/MainActivity.kt
file:
import android.app.Activity
import android.content.Intent
import live.hms.hmssdk_flutter.Constants
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == Constants.SCREEN_SHARE_INTENT_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
data?.action = Constants.HMSSDK_RECEIVER
activity.sendBroadcast(data?.putExtra(Constants.METHOD_CALL, Constants.SCREEN_SHARE_REQUEST))
}
}
For screen sharing in iOS please follow this doc.
Pass the iOSScreenshareConfig
in the HMSPrebuiltOptions
parameter of the HMSPrebuilt
widget to enble screen share in your app.
// Pass the correct App Group & Preferred Extension parameters in HMSIOSScreenshareConfig class.
HMSPrebuilt(
roomCode: meetingLinkController.text.trim(),
options: HMSPrebuiltOptions(
iOSScreenshareConfig: HMSIOSScreenshareConfig(
appGroup: "appGroup", // App Group value linked to your Apple Developer Account
preferredExtension: "preferredExtension" // Name of the Broadcast Upload Extension Target created in Xcode
)));
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<activity
....
android:supportsPictureInPicture="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
... />
MainActivity.kt
file("android/app/src/main/kotlin/live/hms/flutter/MainActivity.kt") add: import android.content.res.Configuration
import android.os.Build
import live.hms.hmssdk_flutter.methods.HMSPipAction
import live.hms.hmssdk_flutter.Constants
override fun onUserLeaveHint() {
super.onUserLeaveHint()
// This should only work for android version above 8 since PIP is only supported after
// android 8 and will not be called after android 12 since it automatically gets handled by android.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
HMSPipAction.autoEnterPipMode(this)
}
}
There are some minimum requirements for running PIP in iOS:
YES
.That's all there is to it! These steps will help you create a fully functional video-calling application in Flutter.
Run your application and test it out!
Now that you have the 100ms Prebuilt component embedded in your Flutter app, you might want to tweak it further to appeal it more to your use case. 100ms Prebuilt allows complete no code customization with 100ms dashboard using;
Here's a quick guide on how you can customize Prebuilt.
Our Prebuilt roadmap is loaded with awesome plans. If you're eager to join this journey and be a part of the action, contributing your expertise, we'd love to have you on board! 🌟, do consider joining our #Prebuilt discord channel. Adiós👋
Engineering
Share
Related articles
See all articles