Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
tshedor committed Aug 25, 2024
1 parent b3d0370 commit d4cc9e5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
9 changes: 3 additions & 6 deletions example_supabase/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

This minimal example demonstrates how to use Brick with [Supabase](https://supabase.com/). Follow the instructions below to get started.

Every Supabase project comes with a [ready-to-use REST API](https://supabase.com/docs/guides/api) using [PostgREST](https://postgrest.org/) which Brick can use to interact with the database.

## Setting up the Supabase project

1. **Create the table**: Run the following SQL command in your Supabase SQL editor to create the customers table:
Expand All @@ -20,19 +18,18 @@ CREATE TABLE customers (
2. **Insert Dummy Data**: Insert some dummy data into the customers table by running the following SQL command

```sql
INSERT INTO customers (id, first_name, last_name, created_at) VALUES
INSERT INTO customers (id, first_name, last_name, created_at) VALUES
('a8098c1a-f86e-11da-bd1a-00112444be1e', 'Bruce', 'Fortner', NOW()),
('b8098c1a-f86e-11da-bd1a-00112444be1e', 'Jane', 'Smith', NOW()),
('c8098c1a-f86e-11da-bd1a-00112444be1e', 'Alice', 'Johnson', NOW());
```


3. **Enable Anonymous Sign-Ins**: Go to your Supabase dashboard, navigate to Settings > Authentication > User Signups, and enable anonymous sign-ins.

## Setting up the Flutter example project

4. **Update Environment Variables**: Open the `lib/env.dart` file and update it with your Supabase project URL and anonymous key. You can find these values in the Supabase dashboard under Settings > API.
4. **Update Variables**: Update `main.dart` with your Supabase project URL and anonymous key. You can find these values in the Supabase dashboard under Settings > API.

## Running the Flutter app

5. **Run the Flutter Project**: This example supports iOS and Android. Make sure run `flutter create .` first.
5. **Run the Flutter Project**: This example supports iOS and Android. Make sure run `flutter create .` first.
4 changes: 2 additions & 2 deletions example_supabase/lib/brick/repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ class Repository extends OfflineFirstWithSupabaseRepository {

static Future<void> initializeSupabaseAndConfigure({
required String supabaseUrl,
required String anonKey,
required String supabaseAnonKey,
}) async {
final (client, queue) = OfflineFirstWithSupabaseRepository.clientQueue(
databaseFactory: databaseFactory,
);

final supabase = await Supabase.initialize(
url: supabaseUrl,
anonKey: anonKey,
anonKey: supabaseAnonKey,
httpClient: client,
);

Expand Down
7 changes: 5 additions & 2 deletions example_supabase/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import 'package:flutter/material.dart';
import 'package:pizza_shoppe/brick/models/customer.model.dart';
import 'package:pizza_shoppe/brick/repository.dart';

const supabaseUrl = 'YOUR_SUPABASE_URL';
const supabaseAnonKey = 'YOUR_SUPABASE_ANON_KEY';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
Expand Down Expand Up @@ -34,8 +37,8 @@ class _MyHomePageState extends State<MyHomePage> {
@override
Future<void> initState() async {
await Repository.initializeSupabaseAndConfigure(
supabaseUrl: 'YOUR_SUPABASE_URL',
anonKey: 'YOUR_SUPABASE_ANON_KEY',
supabaseUrl: supabaseUrl,
supabaseAnonKey: supabaseAnonKey,
);
await Repository().initialize();
// Note that subsequent boots of the app will use cached data
Expand Down

0 comments on commit d4cc9e5

Please sign in to comment.