backendless_sdk 7.3.2 backendless_sdk: ^7.3.2 copied to clipboard
Flutter plugin for Backendless SDK. It provides access to the Backendless services that enable the server-side functionality for developing and running mobile and desktop apps.
import 'package:backendless_sdk/backendless_sdk.dart';
import 'package:flutter/material.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
static const String APP_ID = '756C19D2-DF82-9D99-FF9C-9BFD2F85DC00';
static const String ANDROID_KEY = 'D3514DD9-C127-4BDA-BA06-AF0DF15EBEFB';
static const String IOS_KEY = 'A4470C03-FC06-4009-BD47-9077033BF7F6';
static const String JS_KEY = '102FA6B3-488F-415B-84DF-0B4F3B6352E6';
@override
void initState() {
super.initState();
}
void buttonPressed() async {
// create a Map object. This will become a record in a database table
Map testObject = new Map();
// add a property to the object.
// The property name ("foo") will become a column in the database table
// The property value ("bar") will be stored as a value for the stored record
testObject["foo"] = "bar";
// Save the object in the database. The name of the database table is "TestTable".
/*Backendless.data.of("TestTable").save(testObject).then((response) =>
print("Object is saved in Backendless. Please check in the console."));*/
try {
await Backendless.initApp(
applicationId: APP_ID,
androidApiKey: ANDROID_KEY,
iosApiKey: IOS_KEY,
jsApiKey: JS_KEY);
var rsLog =
await Backendless.userService.login('hdhdhd@gmail.com', '123234');
print(rsLog);
var rsuser = await Backendless.userService.getCurrentUser();
print(rsuser);
} catch (ex) {
print('EXP in Login:\n$ex');
}
}
void buttonPressed2() async {
try {
var rt = Backendless.data.of('TestTable').rt();
rt.addCreateListener((response) {
print('create:\n$response');
});
rt.addUpdateListener((response) {
print('update:\n$response');
});
} catch (ex) {
print('EXP in RT:\n$ex');
}
}
void buttonPressed3() async {
try {
var res = await Backendless.data.of('TestTable').find();
print(res);
} catch (ex) {
print('EXP in Find:\n$ex');
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(child: Text("Press"), onPressed: buttonPressed),
ElevatedButton(
child: Text("RT Connect"), onPressed: buttonPressed2),
ElevatedButton(child: Text("Fetch"), onPressed: buttonPressed3),
],
)),
),
);
}
}