backendless_sdk 7.1.2 backendless_sdk: ^7.1.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() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
static const String APP_ID = "D7022AC3-0526-5B74-FF32-4EBB8B955800";
static const String ANDROID_KEY = "7397F3A9-E148-4CDB-9FCB-05765D9CFA9E";
static const String IOS_KEY = "5ED16103-D623-45AC-8778-8D08912F0446";
static const String JS_KEY = "D5357119-0FD1-4A8D-9F9F-5587B7C3CA44";
@override
void initState() {
super.initState();
Backendless.initApp(
applicationId: APP_ID,
androidApiKey: ANDROID_KEY,
iosApiKey: IOS_KEY,
jsApiKey: JS_KEY);
}
void buttonPressed() {
// 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";
DataQueryBuilder queryBuilder = DataQueryBuilder();
// 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."));
Backendless.userService
.findByRole('flutterRole', loadRoles: true, queryBuilder: queryBuilder)
.then((value) => print('found values: $value'));
}
@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)
],
)),
),
);
}
}