Flutter
Parse SDK (REST)

Basic Data Operations

10min

This guide demonstrates how to manage Parse Objects on Back4App using the Flutter plugin for Parse Server. You'll learn the basic CRUD operations: Create, Read, Update, and Delete. This tutorial uses a simple ToDo app to illustrate these operations.

Back4app Backend data storage revolves around the ParseObject, which holds key-value pairs of JSON-compatible data. The Back4App Data Storage accommodates a wide range of common data types, including strings, numbers, booleans, DateTime, GeoPoints, Pointers, Relations, as well as lists and objects. Essentially, it supports any data that can be encoded in JSON format, providing a flexible and robust solution for various data storage needs.

Prerequisites

To complete this tutorial, you will need:

1. Create Object

The saveTodo function creates a new task with a title and a done status set to false. Here’s how it works:

  1. Initialize Parse Object setting its Attributes: Create an instance of ParseObject for your class (e.g., 'Todo'). Use the set method to define the key-value pairs.
  2. Save the Object: Call the save method to store the object in the database.
Dart


2. Read Object

The getTodo function queries the database and returns a list of tasks. Here’s how it works:

  1. Initialize the Query: Create an instance of QueryBuilder for your class.
  2. Execute the Query: Use the query method to retrieve data.
  3. Handle the Response: Check if the query was successful and process the results.
Dart


Update the ListView.builder function to extract and display Parse object values:

Dart


3. Update Object

The updateTodo function updates the status of an existing task. Here’s how it works:

  1. Initialize the Parse Object and Set Attributes: Create an instance of ParseObject and set its objectId. Use the set method to update key-value pairs.
  2. Save the Object: Call the save method to update the object in the database.
Dart


4. Delete Object

The deleteTodo function removes an existing task from the database. Here’s how it works:

  1. Initialize the Parse Object: Create an instance of ParseObject and set its objectId.
  2. Delete the Object: Call the delete method to remove the object from the database.
Dart


Full Example Code

Here’s the complete code for a simple ToDo app integrated with Back4app Backend.

Dart


Your App should look like this:

Document image


Conclusion

You have now implemented the basic CRUD operations in a Flutter app using Parse on Back4App. This tutorial demonstrated how to add, retrieve, update, and delete tasks in a ToDo app.