backendless_sdk 8.0.0-alpha.3 backendless_sdk: ^8.0.0-alpha.3 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:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:backendless_sdk/backendless_sdk.dart';
import 'main.reflectable.dart';
var rt = Backendless.rt;
void main() async {
WidgetsFlutterBinding.ensureInitialized();
initializeReflectable();
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String? token = 'Text';
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
try {
await Backendless.initApp(
applicationId: 'APP_ID',
androidApiKey: 'ANDROID_API_KEY',
iosApiKey: 'IOS_API_KEY',
);
} on Exception {
if (kDebugMode) {
print('Failed to init application.');
}
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
children: [
TextButton(onPressed: buttonPressed, child: const Text('Press')),
],
),
),
),
);
}
void buttonPressed() async {
// create a Map object. This will become a record in a database table
Map testObject = {};
// 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) {
if (kDebugMode) {
print("Object is saved in Backendless. Please check in the console.");
}
});
}
}
@reflector
class TestTable {
String? foo;
String? nameTimeColumn;
}
@reflector
class Person {
final String noZeroField;
int? age;
String? name;
Point? p1;
Person(this.noZeroField);
}