auro_stream_live 1.1.3
auro_stream_live: ^1.1.3 copied to clipboard
Auro Stream Live Stream Plugin for iOS/Android/Desktop
example/lib/main.dart
import 'package:auro_stream_live/auro_stream_live.dart';
import 'package:auro_stream_live_example/home_screen.dart';
import 'package:flutter/material.dart';
import 'live_service.dart';
void main() {
AuroStreamLive.initialize(
projectId: 'projectId',
apiKey: 'apiKey',
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'AuroStream Live',
home: LoginScreen(),
);
}
}
class LoginScreen extends StatefulWidget {
const LoginScreen({super.key});
@override
State<LoginScreen> createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
AuroStreamLiveServices? auroStreamLiveServices;
final userController = TextEditingController();
@override
void initState() {
auroStreamLiveServices = AuroStreamLiveServices();
auroStreamLiveServices!.connectServer();
super.initState();
}
void connect() {
/// Should have unique String for user like username or id
final username = userController.text.trim();
if (username.isNotEmpty) {
auroStreamLiveServices!.initUsername(usernameId: username);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => HomeScreen(
auroStreamLiveServices: auroStreamLiveServices!,
),
),
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
'UserName',
style: TextStyle(color: Color(0xff0445A2), fontSize: 16),
),
const SizedBox(height: 8),
TextFormField(
controller: userController,
decoration: const InputDecoration(
hintText: 'Enter your username..',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.person),
),
),
const SizedBox(height: 50),
Align(
alignment: Alignment.center,
child: MaterialButton(
color: const Color(0xff0445A2),
onPressed: () {
connect();
},
child: const Text(
'Join',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.w700),
),
),
),
],
),
),
);
}
}