Mastering Note-Taking with FlutterFlow and Supabase: A Complete Guide

Anis MarrouchiAI Bot
By Anis Marrouchi & AI Bot ·

Loading the Text to Speech Audio Player...

In this comprehensive tutorial, you'll learn how to build a robust note-taking app using FlutterFlow for the front-end and Supabase for the backend. With this guide, we'll walk you through every step, from setting up your Supabase database to integrating it with FlutterFlow, ensuring even beginners can follow along effectively. Let's get started!

This guide assumes some basic understanding of FlutterFlow and Supabase. For further details, refer to the official documentation for FlutterFlow and Supabase docs.

Setting up the Supabase Database

Complete these fundamental steps to set up your Supabase database before diving into the app's UI and logic.

1. Creating a New Project in the Supabase Dashboard

Start by visiting the Supabase homepage, and click "Start a project" or simply log in.

  1. Create New Project: Give your project a unique name and set a strong database password. Select the preferred database server region and hit "Create new project."

2. Creating the Users Table

In the Supabase dashboard, navigate to the Table Editor to create a new table named users. Your table structure should resemble this:

Fields:

  • id: UUID (Primary Key)
  • email: Text
  • name: Text
  • created_at: Timestamp (Default: NOW())

Set the primary key for id and configure the necessary constraints.

3. Creating the Notes Table

Next, create another table named notes with the following schema:

Fields:

  • id: UUID (Primary Key)
  • title: Text
  • description: Text
  • image_url: Text (for storing image paths)
  • created_at: Timestamp (Default: NOW())

4. Setting Up a Storage Bucket in Supabase

To store images related to notes, create a storage bucket:

  1. Create Public Bucket: Go to the Storage section, name your bucket notes, and keep it public.

  2. Set Policies: Under Configuration > Policies, create a policy for inserting files with these permissions:

    (bucket_id = 'notes'::text) AND (lower((storage.foldername(name))[1]) = (auth.uid())::text)

Connect Your FlutterFlow App With Supabase

Step 1: Clone the Starter Project

Clone the provided FlutterFlow starter project to begin integrating Supabase with FlutterFlow.

Step 2: Configure Authentication

Navigate to Settings > App Settings > Authentication in FlutterFlow:

  1. Enable Authentication: Set the Authentication Type to Supabase.
  2. Set Pages: Configure the Entry Page to your login screen and Logged In Page to your home screen.

Step 3: Integrate Supabase

  1. Enable Supabase: Turn on Supabase in the Integrations section.
  2. Add API URL and Anon Key: These can be found in your Supabase project settings.
  3. Fetch Schema: Click "Get Schema" to retrieve database tables.

Step 4: Build the Login Page

Design a user-friendly login page with text fields for credentials:

  1. Add 'On Tap' Action: On the 'Create Account' button, add a new action Backend/Database > Supabase > Insert Row to store user data.
const userInsertAction = {
  actionType: 'Insert Row',
  table: 'users',
  fields: {
    id: AuthenticatedUser.uid,
    email: TextField.email,
    name: TextField.name,
    created_at: GlobalProperties.CurrentTime,
  },
};

Step 5: Add Sign-in Logic

Repeat the process for the 'Sign In' button, but set the action type to Login.

Step 6: Implement Logout Functionality

Create a logout action on the HomeListPage's logout button:

  1. Action Type: Logout
  2. Properties: No additional settings required.

Retrieving and Displaying Notes

Step 7: Create Note List View

  1. Navigate to Note List Page:
  2. Query Notes Table: On the HomeListPage, set a Supabase query to retrieve the list of notes.
const notesQuery = {
  queryType: 'List of Rows',
  table: 'notes',
  fields: ['title', 'created_at'],
};

Bind data from the notes table to the NoteItem widgets:

  • Title: Bind to notes Row > title
  • Date: Bind to notes Row > created_at

Step 9: Define Navigation Actions

  1. Navigate to NoteDisplayPage: On tap of NoteItem, navigate to NoteDisplayPage, passing the selected note data.

Step 10: Display Note Content

Bind the received note data to UI elements on the NoteDisplayPage:

  • Title, Description, and Image

Adding New Notes

Step 11: Navigate to CreateNotePage

Set the Create button to navigate from HomeListPage to CreateNotePage without parameters.

Step 12: File Upload Functionality

Add an action to the image upload button to save the file to Supabase.

const uploadAction = {
  uploadType: 'Supabase',
  bucket: 'notes',
  filePath: URL.path,
};

Step 13: Conditional Visibility for Uploaded Images

Set up conditional visibility for the image widget to prevent null exceptions:

  1. Condition: Uploaded file URL is not empty.

Step 14: Create Note Action

Assign backend actions to the 'Create' button to insert a new row in the notes table and navigate back.

const createNoteAction = {
  actionType: 'Insert Row',
  table: 'notes',
  fields: {
    title: TextField.title,
    description: TextField.description,
    image_url: WidgetState.uploadedFileURL,
    created_at: GlobalProperties.CurrentTime,
  },
};

Conclusion

Congratulations! You have successfully built a note-taking app using FlutterFlow and Supabase. This guide provided a full walkthrough, from database setup to CRUD operations, ensuring you have a solid foundation to expand your app further.

For more detailed tutorials and resources, refer to the official FlutterFlow documentation and Supabase docs.

Thank you for following this guide, and happy coding!

Reference: "FlutterFlow Docs Troubleshooting Guides Docs FeedbackAsk or Search⌘ + K" available on FlutterFlow Documentation.


Want to read more tutorials? Check out our latest tutorial on Guide to HeyGen Template API.

Discuss Your Project with Us

We're here to help with your web development needs. Schedule a call to discuss your project and how we can assist you.

Let's find the best solutions for your needs.