Supabase flutter user management demo app.

Overview

Supabase Flutter User Management

This example will set you up for a very common situation: users can sign up with a magic link and then update their account with public profile information, including a profile image.

Technologies used

  • Frontend:
    • Flutter SDK - Google's UI toolkit for crafting beautiful, natively compiled applications for mobile, web, and desktop from a single codebase.
    • supabase_flutter for user management and image storage uploading.
  • Backend:
    • app.supabase.io: hosted Postgres database with restful API for usage with supabase_flutter.

Build from scratch

1. Create new project

Sign up to Supabase - https://app.supabase.io and create a new project. Wait for your database to start.

2. Run "User Management" Quickstart

Once your database has started, run the "User Management Starter" quickstart. Inside of your project, enter the SQL editor tab and scroll down until you see User Management Starter: Set up a Public Profiles table which you can access with your API.

3. Get the URL and Key

Go to the Project Settings (the cog icon), open the API tab, and find your API URL and anon key, you'll need these in the next step.

The anon key is your client-side API key. It allows "anonymous access" to your database, until the user has logged in. Once they have logged in, the keys will switch to the user's own login token. This enables row level security for your data. Read more about this below.

image

NOTE: The service_role key has full access to your data, bypassing any security policies. These keys have to be kept secret and are meant to be used in server environments and never on a client or browser.

4. Setup deeplink redirect urls

Go to the Authentication Settings page (the user icon). Enter the flutter app redirect url below into Additional Redirect URLs field. Then click Save.

io.supabase.flutterdemo://login-callback

authentication settings page

5. Setup Github 3rd party logins

Follow the guide https://supabase.io/docs/guides/auth#third-party-logins

6. Run the flutter application

  • Go to lib/utils/constants.dart file
  • Update SUPABASE_URL and SUPABASE_ANNON_KEY with your URL and Key
  • Run the application: flutter run

Supabase details

Postgres Row level security

This project uses very high-level Authorization using Postgres' Role Level Security. When you start a Postgres database on Supabase, we populate it with an auth schema, and some helper functions. When a user logs in, they are issued a JWT with the role authenticated and thier UUID. We can use these details to provide fine-grained control over what each user can and cannot do.

This is a trimmed-down schema, with the policies:

-- Create a table for Public Profiles
create table profiles (
  id uuid references auth.users not null,
  updated_at timestamp with time zone,
  username text unique,
  avatar_url text,
  website text,

  primary key (id),
  unique(username),
  constraint username_length check (char_length(username) >= 3)
);

alter table profiles enable row level security;

create policy "Public profiles are viewable by everyone."
  on profiles for select
  using ( true );

create policy "Users can insert their own profile."
  on profiles for insert
  with check ( auth.uid() = id );

create policy "Users can update own profile."
  on profiles for update
  using ( auth.uid() = id );

-- Set up Realtime!
begin;
  drop publication if exists supabase_realtime;
  create publication supabase_realtime;
commit;
alter publication supabase_realtime add table profiles;

-- Set up Storage!
insert into storage.buckets (id, name)
values ('avatars', 'avatars');

create policy "Avatar images are publicly accessible."
  on storage.objects for select
  using ( bucket_id = 'avatars' );

create policy "Anyone can upload an avatar."
  on storage.objects for insert
  with check ( bucket_id = 'avatars' );

create policy "Anyone can update an avatar."
  on storage.objects for update
  with check ( bucket_id = 'avatars' );

Authors

Supabase is open source. We'd love for you to follow along and get involved at https://github.com/supabase/supabase

You might also like...

A basic demo example for integrating between Appwrite & Flutter 💙

A basic demo example for integrating between Appwrite & Flutter 💙

🔖 Todo With Flutter A simple todo app built with Flutter and Appwrite 🎬 Getting Started Appwrite is an end-to-end backend server for Web, Mobile, Na

Dec 15, 2022

A fully responsive BMI calculator app made using flutter and dart with beautiful minimalistic user interface design and easy to use .

A fully responsive BMI calculator app made using flutter and dart with beautiful minimalistic user interface design and easy to use .

BMI_Calculator_Flutter A fully responsive BMI calculator app made using flutter and dart with beautiful minimalistic user interface design and easy to

Oct 9, 2021

A flutter app where the user could add their credit cards and see a summary of their expenses

A flutter app where the user could add their credit cards and see a summary of their expenses

Card Controller 💳 Card Controller foi um projeto realizado com o intuito de aprendizagem e prática da linguagem de programação Dart em conjunto com o

Jul 26, 2022

A News app that provides users with the outmost user experiance built with Google's flutter

A News app that provides users with the outmost user experiance built with Google's flutter

A News app that provides users with the outmost user experiance built with Google's flutter

Jun 30, 2022

This app contain two pages. In first page user will see the list of places to visit and in other page detail of places will be shown. Apart from that there is route transition, hero and staggered animation while navigating to the detail page.

This app contain two pages. In first page user will see the list of places to visit and in other page detail of places will be shown. Apart from that there is route transition, hero and staggered animation while navigating to the detail page.

travell_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if t

Dec 3, 2022

Iron Yard: An android cloth ironing user interface built in flutter.

Iron Yard: An android cloth ironing user interface built in flutter.

Iron Yard Iron Yard: An android cloth ironing user interface built in flutter. If you found this project helpful or you learned something from the sou

Jul 31, 2021

An application built using Flutter that is to conduct a quiz and provide the user with the result of the quiz.

An application built using Flutter that is to conduct a quiz and provide the user with the result of the quiz.

Quizzler Challenge Solution This is a companion project to The App Brewery's Complete Flutter Development Bootcamp, check out the full course at www.a

Sep 8, 2022

The User application for the project The Shared Backpack

The User application for the project The Shared Backpack

Shared Backpack User App Components The User app Section for the Shared-Backpack Project. Shared Backpack user app Comunity Impact The project focuses

Aug 15, 2021

A welcome page for a user, as well as a brief overview of the work of the application

dalilak A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this

Oct 15, 2021
Comments
  • Signup Screen fails on email verification required by logging in user.

    Signup Screen fails on email verification required by logging in user.

    The response api for signup has been changed such that a user object is now returned so the check in the signup_screen fails when email verification is turned on.. Currently the code states if (response.data == null && response.user == null) however it should now be something like if (response.data == null && (response.user != null && response.user?.emailConfirmedAt == null))

    Thanks, Julian

    opened by JulianSwales 0
Owner
Hieu Pham
developer | Discord: hieu#5896
Hieu Pham
A Dart client for Supabase

supabase-dart A Dart client for Supabase. What is Supabase Supabase is an open source Firebase alternative. We are a service to: listen to database ch

Supabase 392 Jan 7, 2023
This is a User Profile where the user can edit their information.

Flutter User Profile App This repository shows how I built a simple User Profile UI using Flutter. Please note that I was unable to get the Profile Im

Ivanro Lagazo 20 Jan 4, 2023
Building a simple Flutter app for practicing and understanding the GetX State Management and Route Management.

GetX State Management Demo with full understanding of State Management (with GetBuiler, GetX, Obx), Route Management and SnackBar.

TAD 4 Oct 2, 2022
A simple flutter app with demo implementation of redux.

Flutter Redux Tutorial Redux Project is just a quick guide for implementation of redux.dart and flutter_redux . Written in dart using Flutter SDK. Ple

Pawan Kumar 46 Jun 16, 2022
Flutter app demo multiple call with WebRTC and SFUs Architecture

Video Call Flutter App (SFUs Architecture) ?? Description: This is sandbox video call application using Flutter and WebRTC. SFUs – Selective Forwardin

Dao Hong Vinh 15 Dec 5, 2022
Food App Demo for learning Flutter

foodapp_demo Food App Demo for learning Flutter Slicing UI SetState StateFull Widget LINK TUTORIAL https://www.youtube.com/watch?v=1Xd15C2k4OU&list=PL

Ronaldi 1 Mar 12, 2022
App to showcase demo for how to have Clean Architecture in Flutter with Get_It for dependency injection

App to showcase demo for how to have Clean Architecture in Flutter with Get_It for dependency injection, BLoC for state maintainence and Hive for persisting data into database.

Rohan Kandwal 1 Mar 19, 2022
Flutter demo application for Apple TV (tvos) using custom Flutter engine

Flutter for Apple TV A modification of the Flutter engine + test application to demonstrate that Flutter applications run on Apple TV This project (an

LibertyGlobal 181 Dec 30, 2022
A basic demo example for integrating between Appwrite & Flutter 💙

?? Quiz With Flutter A simple Quiz App built with Flutter and Appwrite ?? Getting Started ?? Install Appwrite Follow our simple Installation Guide to

Appwrite 35 Nov 22, 2022
A demo built with Flutter and Appwrite backend for Hacktoberfest 2021.

Artistry: Appwrite - Flutter Demo ?? Artistry is a demo app built with flutter and Appwrite backend for Hacktoberfest 2021, that demonstrates how to p

Divyam joshi 23 Dec 16, 2022