Yeah sure
My code is identical to this with the exception of the table name and column names. This example displays one list from one table in Backendless. I’d like to be able to display a second list underneath it with data from a second table.
So this is the main.dart file
import 'package:flutter/material.dart';
import 'package:backendless_sdk/backendless_sdk.dart';
import 'movies.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'RT Database Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(
title: 'Watched Movies'
),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State {
static const String API_HOST = "https://api.backendless.com";
static const String APP_ID = "YOUR_APP_ID";
static const String ANDROID_APP_KEY = "YOUR_ANDROID_API_KEY";
static const String IOS_APP_KEY = "YOUR_IOS_API_KEY";
IDataStore<Map> moviesStore = Backendless.data.of('Movies');
List<Map> moviesList = [];
@override
void initState() {
super.initState();
_initBackendless();
_enableRealTime();
getMovies();
}
void _initBackendless() {
Backendless.setUrl(API_HOST);
Backendless.initApp(APP_ID, ANDROID_APP_KEY, IOS_APP_KEY);
}
void _enableRealTime() {
// we will add code for Real Time Database here
}
void getMovies() {
DataQueryBuilder queryBuilder = DataQueryBuilder()
..pageSize = 100
..sortBy = ['created'];
moviesStore.find(queryBuilder).then((response) => setState(() => moviesList = response));
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Movies(moviesList),
);
}
}
And this is the movies.dart file
import 'package:flutter/material.dart';
class Movies extends StatelessWidget {
final List<Map> moviesList;
Movies(this.moviesList);
Widget _buildMovieItem(BuildContext context, int index) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(moviesList[index]['title'],
style: TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
Text(moviesList[index]['description'],
style: TextStyle(
color: Colors.black,
fontSize: 15,
),
),
Row(
children: [
Text(moviesList[index]['rating'],
style: TextStyle(
color: Colors.black,
fontSize: 15,
fontWeight: FontWeight.bold,
),
),
Container(
margin: EdgeInsets.fromLTRB(10, 0, 0, 0),
child: Text(moviesList[index]['release_year'],
style: TextStyle(
color: Colors.black,
fontSize: 15,
fontWeight: FontWeight.bold,
),
),
),
],
),
Divider(
color: Colors.black,
),
],
);
}
@override
Widget build(BuildContext context) {
return ListView.builder(
padding: EdgeInsets.all(10),
itemBuilder: _buildMovieItem,
itemCount: moviesList.length,
);
}
}
```