The Dubit Flutter Adapter makes it easy to integrate Dubit video calls into your Flutter app. Here's a clean and functional example to get you started. Follow the steps below to implement the adapter in your project.
In your pubspec.yaml file, include the dependency for the Dubit Adapter:
yaml
Copy code
dependencies:
dubit_flutter_adapter:
git:
url: https://github.com/zardamhussain/dubit_adapter
ref: main
Run flutter pub get to fetch the dependency.
1. Initialize the Adapter:
To start using the Dubit adapter, first, instantiate the Dubit
object and set up an event listener to handle incoming events.
final dubit = Dubit();
dubit.onEvent.listen((event) {
print('Received event data: ${event.label} ${event.value}');
});
2. Join the call to listen the events:
Use the start
method to begin a call by providing the webCallUrl
. Replace the URL with your specific Dubit video call link.
dubit.start(
webCallUrl: 'https://trydubit.daily.co/${room_id}'
);
3. Leave the Call:
When you're ready to stop listening the events, simply call the stop
method.
dubit.stop();
Here's the complete implementation:
import 'package:dubit_flutter_adapter/dubit_flutter_adapter.dart';
void main() {
final dubit = Dubit();
// Listen for events
dubit.onEvent.listen((event) {
print('Received event data: ${event.label} ${event.value}');
});
// Start the call
dubit.start(webCallUrl: 'https://trydubit.daily.co/${room_id}');
// Example: Stop the call (triggered by a button press or event)
// dubit.stop();
}