vdotok_stream 0.0.9 vdotok_stream: ^0.0.9 copied to clipboard
By using this package you can connect with vdotok and use vdotok services. you can make one 2 one, many 2 many, Group calls , broadcast etc.
example/lib/main.dart
import 'dart:async';
import 'dart:io';
import 'package:data_connection_checker/data_connection_checker.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:vdotok_stream/vdotok_stream.dart';
import 'package:vdotok_stream_example/src/core/providers/call_provider.dart';
import 'package:vdotok_stream_example/src/core/providers/contact_provider.dart';
import 'package:vdotok_stream_example/src/core/providers/groupListProvider.dart';
import 'src/core/providers/auth.dart';
import 'src/home/homeIndex.dart';
import 'src/login/SignInScreen.dart';
import 'src/routing/routes.dart';
import 'src/splash/splash.dart';
import 'package:provider/provider.dart';
import 'constant.dart';
class MyHttpOverrides extends HttpOverrides {
@override
HttpClient createHttpClient(SecurityContext context) {
return super.createHttpClient(context)
..badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
}
}
void main() {
HttpOverrides.global = new MyHttpOverrides();
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
bool state = true;
bool connectionState = false;
bool keepShowing = false;
bool isDeviceConnected = false;
bool isdev = true;
StreamSubscription subscription;
GlobalKey<ScaffoldMessengerState> rootScaffoldMessengerKey;
@override
void initState() {
super.initState();
rootScaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
checkStatus();
checkConnectivity();
}
@override
void dispose() {
subscription.cancel();
super.dispose();
}
checkStatus() async {
if (!kIsWeb) {
bool connectivity = await DataConnectionChecker().hasConnection;
print("this is for web $connectivity");
if (connectivity == true) {
setState(() {
state = true;
print("here in state circle");
});
} else {
setState(() {
state = false;
});
}
}
}
void checkConnectivity() async {
isDeviceConnected = false;
if (!kIsWeb) {
DataConnectionChecker().onStatusChange.listen((status) async {
print("this on listener");
isDeviceConnected = await DataConnectionChecker().hasConnection;
print("this is is connected $isDeviceConnected state $state");
if (isDeviceConnected == true) {
if (state == true)
state = false;
else {
setState(() {
isdev = true;
});
// showSnackbar("Internet Connected", whiteColor, Colors.green, false);
}
} else {
{
setState(() {
isdev = false;
});
// showSnackbar(
// "No Internet Connection", whiteColor, primaryColor, true);
}
}
});
}
}
showSnackbar(text, Color color, Color backgroundColor, bool check) {
if (check == false) {
rootScaffoldMessengerKey.currentState
..hideCurrentSnackBar()
..showSnackBar(SnackBar(
content: Text(
'$text',
style: TextStyle(color: color),
),
backgroundColor: backgroundColor,
duration: Duration(seconds: 2),
));
} else if (check == true) {
rootScaffoldMessengerKey.currentState
..hideCurrentSnackBar()
..showSnackBar(SnackBar(
content: Text(
'$text',
style: TextStyle(color: color),
),
backgroundColor: backgroundColor,
duration: Duration(days: 1),
));
}
}
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => AuthProvider()..isUserLogedIn()),
ChangeNotifierProvider(create: (_) => CallProvider()),
ChangeNotifierProvider(create: (_) => ContactProvider()),
ChangeNotifierProvider(create: (_) => GroupListProvider()),
],
child: MaterialApp(
scaffoldMessengerKey: rootScaffoldMessengerKey,
debugShowCheckedModeBanner: false,
title: 'Vdotok Video',
theme: ThemeData(
colorScheme: ColorScheme.fromSwatch(
primarySwatch: Colors.grey,
).copyWith(),
accentColor: primaryColor,
primaryColor: primaryColor,
scaffoldBackgroundColor: Colors.white,
textTheme: TextTheme(
bodyText1: TextStyle(color: secondaryColor),
bodyText2: TextStyle(color: secondaryColor), //Text
)),
onGenerateRoute: Routers.generateRoute,
home: Consumer<AuthProvider>(
builder: (context, auth, child) {
if (auth.loggedInStatus == Status.Authenticating)
return SplashScreen();
else if (auth.loggedInStatus == Status.LoggedIn) {
return HomeIndex(state: isdev);
} else
return SignInScreen();
},
),
),
);
}
}
class Test extends StatefulWidget {
@override
_TestState createState() => _TestState();
}
class _TestState extends State<Test> {
SignalingClient signalingClient;
@override
void initState() {
// TODO: implement initState
signalingClient = SignalingClient.instance;
// signalingClient.methodInvoke();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
StreamBuilder(
stream: signalingClient.numberStream(),
builder: (BuildContext context, snapshot) {
if (snapshot.hasData)
return Text(snapshot.data.toString());
else if (snapshot.hasError)
return Text("no data found");
else
return Text("no data found");
}),
RaisedButton(
onPressed: () {
// signalingClient.handleLocationChanges();
},
child: Text("invoke method"),
)
],
),
),
);
}
}