---
title: Flutter-completers-tutorial-markdown
slug: french/b2fH-flutter-completers-tutorial-markdown
createdAt: 2024-08-21T07:05:34.751Z
---

# How to Use Flutter Completers with a Backend on Back4app

## Introduction

In Flutter, handling asynchronous operations is typically done using `Futures` and `Streams`. However, there are scenarios where these two alone may not suffice. For advanced control over `Futures`, you can use a `Completer`. A `Completer` allows you to programmatically complete a `Future`, giving you finer control over asynchronous operations. This tutorial will walk you through how to use Flutter `Completers` in an application that interacts with a backend on Back4app.

By the end of this tutorial, you will learn how to use `Completers` to manage asynchronous tasks in a Flutter application and integrate these tasks with a backend service provided by Back4app. We will create a simple app that fetches data from a Back4app backend and uses a `Completer` to control the flow of the application.

## Prerequisites

To complete this tutorial, you will need:

- A Back4app account. Sign up for a free account at [Back4app.com](https://www.back4app.com).
- A Flutter development environment set up on your local machine. Follow the [Flutter installation guide](https://flutter.dev/docs/get-started/install) if you haven't set it up yet.
- Basic knowledge of Dart and asynchronous programming in Flutter. If you need a refresher, check out the [Flutter Async Programming Guide](https://dart.dev/codelabs/async-await).

## Step 1 – Setting Up Your Back4app Backend

First, let's set up a simple backend on Back4app that our Flutter application will interact with.

1. **Log in to your Back4app account** and create a new project.
2. **Set up a new Parse Class** named `Task`, which will store tasks that our Flutter app will fetch. Add the following columns to the `Task` class:
   - `name` (String): The name of the task.
   - `status` (Boolean): The status of the task (completed or not).
3. **Add a few sample tasks** in the Back4app database to test with. For example:
   - Task 1: `name = "Complete Flutter tutorial", status = true`
   - Task 2: `name = "Start new project", status = false`

Your Back4app backend is now ready to be accessed by the Flutter app.

## Step 2 – Creating a Flutter Project

Next, we'll create a new Flutter project.

1. Open your terminal or command prompt.
2. Run the following command to create a new Flutter project:
3. Navigate to the project directory:
4. Open the project in your preferred code editor (e.g., VS Code, Android Studio).

## Step 3 – Adding the Parse SDK and Configuring the App

Now, let's add the necessary dependencies to interact with Back4app.

1. Open `pubspec.yaml` and add the following dependencies:
2. Run `flutter pub get` to install the dependencies.
3. In `lib/main.dart`, import the Parse SDK:
4. Initialize Parse in the `main` function:

Replace `'YOUR_APP_ID'` and `'YOUR_CLIENT_KEY'` with your actual Back4app credentials.

## Step 4 – Using Completers to Fetch Data Asynchronously

Now, let's use a `Completer` to fetch data from the Back4app backend and control when the data is available for use in the UI.

1. In `lib/main.dart`, create a new class that will fetch tasks from Back4app using a `Completer`:
2. In the `MyApp` widget, use the `TaskManager` to fetch and display tasks:
3. Run your Flutter app:

You should see a list of tasks fetched from your Back4app backend, with their names and completion status.

## Conclusion

In this tutorial, you learned how to use Flutter `Completers` to manage asynchronous operations and control the flow of data fetching in your application. By integrating with Back4app, you created a simple yet powerful backend for your Flutter app, allowing you to fetch and display data dynamically. This approach can be extended to handle more complex scenarios, such as user authentication, data manipulation, and more.

For more information on using Flutter with Back4app, check out the [Back4app Flutter documentation](https://www.back4app.com/docs/flutter/overview). Happy coding!

