stream_video_flutter 0.3.1 copy "stream_video_flutter: ^0.3.1" to clipboard
stream_video_flutter: ^0.3.1 copied to clipboard

The Official UI package for Stream Video, a service for building video calls, audio rooms, and live-streaming applications.

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:share_plus/share_plus.dart';
import 'package:stream_video_flutter/stream_video_flutter.dart';

import 'core/token_service.dart';
import 'log_config.dart';
import 'screen/login_screen.dart';

const _tag = 'MyApp';

Future<void> main() async {
  //useProxy('192.168.1.73:8888');

  WidgetsFlutterBinding.ensureInitialized();

  await _setupLogger();

  runApp(const MyApp(connectUser: _connectUser));
}

Future<Result<None>> _connectUser(UserInfo user) async {
  streamLog.i(_tag, () => '[connectUser] user: $user');

  final tokenResponse = await const TokenService().loadToken(
    environment: Environment.demo,
    userId: user.id,
  );

  final client = StreamVideo(
    tokenResponse.apiKey,
    user: User(info: user),
    userToken: tokenResponse.token,
  );
  await client.connect();

  StreamBackgroundService.init(
    StreamVideo.instance,
    onNotificationClick: (call) async {
      streamLog.i(_tag, () => '[onNotificationClick] call: $call');
      // TODO navigate to call
    },
    onPlatformUiLayerDestroyed: (call) async {
      streamLog.i(_tag, () => '[onPlatformUiLayerDestroyed] call: $call');
      // TODO
    },
  );

  return const Result.success(none);
}

Future<void> _setupLogger() async {
  const consoleLogger = ConsoleStreamLogger();
  final children = <StreamLogger>[consoleLogger];
  FileStreamLogger? fileLogger;
  if (!kIsWeb) {
    fileLogger = FileStreamLogger(
      AppFileLogConfig('1.0.0'),
      sender: (logFile) async {
        consoleLogger.log(
          Priority.debug,
          'DogFoodingApp',
          () => '[send] logFile: $logFile(${logFile.existsSync()})',
        );
        await Share.shareXFiles(
          [XFile(logFile.path)],
          subject: 'Share Logs',
          text: 'Stream Flutter Example Logs',
        );
      },
      console: consoleLogger,
    );
    children.add(fileLogger);
  }
  StreamLog().validator = (priority, _) => true;
  StreamLog().logger = CompositeStreamLogger(children);
}

class MyApp extends StatelessWidget {
  const MyApp({
    super.key,
    required this.connectUser,
  });

  final ConnectUser connectUser;

  @override
  Widget build(BuildContext context) {
    Call? activeCall;
    if (StreamVideo.isInitialized()) {
      activeCall = StreamVideo.instance.activeCall;
    }
    streamLog.i(_tag, () => '[build] activeCall: $activeCall');

    final darkAppTheme = StreamVideoTheme.dark();
    final lightAppTheme = StreamVideoTheme.light();

    return MaterialApp(
      title: 'Stream Video UI Example',
      theme: ThemeData(
        textTheme: GoogleFonts.robotoMonoTextTheme(),
        extensions: <ThemeExtension<dynamic>>[lightAppTheme],
      ),
      darkTheme: ThemeData(
        textTheme: GoogleFonts.robotoMonoTextTheme(),
        extensions: <ThemeExtension<dynamic>>[darkAppTheme],
      ),
      themeMode: ThemeMode.dark,
      home: LoginScreen(connectUser: connectUser),
      debugShowCheckedModeBanner: false,
    );
  }
}
32
likes
0
points
2.74k
downloads

Publisher

verified publishergetstream.io

Weekly Downloads

The Official UI package for Stream Video, a service for building video calls, audio rooms, and live-streaming applications.

Homepage
Repository (GitHub)
View/report issues

Topics

#video #audio #audioroom #webrtc #livestream

License

unknown (license)

Dependencies

cached_network_image, collection, equatable, flutter, flutter_webrtc, plugin_platform_interface, rate_limiter, stream_video, visibility_detector

More

Packages that depend on stream_video_flutter