rayconnect_client 0.0.1-gamma-1 rayconnect_client: ^0.0.1-gamma-1 copied to clipboard
Rayconnect client on dart
import 'package:flutter/material.dart';
import 'package:rayconnect_client/main.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
RayconnectClient rayconnectClient = new RayconnectClient(appId: 'test');
@override
void initState() {
super.initState();
this.init();
}
void init() async {
if (await this.rayconnectClient.auth.hasToken() == false)
await this.rayconnectClient.auth.asGuest();
String token = await this.rayconnectClient.auth.getToken();
print(token);
String uid = await this.rayconnectClient.auth.getUserId();
print(uid);
bool status = await rayconnectClient.cloudStorage.setItem('name', 'Google');
if (status == true)
rayconnectClient.cloudStorage.getItem('name').then((data) => print(data));
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: FlatButton(
child: Text('Do again'),
onPressed: () => this.init(),
),
),
),
);
}
}