auro_stream_live 1.2.0
auro_stream_live: ^1.2.0 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: 'b0442546973e976cf1b1111df82571e7',
apiKey:
'0c80d2af5e72f4d046c7441a.00fff63195ba65417f2835c6682f20bcb560f169e2c69849243f1c22625a9d8221db064bca25fd2d7250f6d99586120f520907bccea21f600b519cbeba1de10526a9bb7206430709793be399ab3ec5e735052cb26481580764789a490eb96f4465201b72e0c887.b2f3180dc301f19feb25640a',
);
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();
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),
),
),
),
],
),
),
);
}
}