From f41708c662fa349570a87d0bfafd18763c7fd532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20M=C3=BCllner?= Date: Thu, 5 Mar 2026 14:37:09 +0100 Subject: [PATCH] fix(config): use dart-define supabase settings and default to PKCE auth flow --- README.md | 9 ++++++++- lib/main.dart | 20 ++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c1f6360..345818e 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,14 @@ car64 is a Flutter + Supabase Hot Wheels collector app with a fast scanning work ## Local Development 1. Install Flutter (stable) and run `flutter doctor`. -2. Configure Supabase keys in app configuration. +2. Configure Supabase values via build-time variables (`--dart-define`), for example: + + ```bash + flutter run \ + --dart-define=SUPABASE_URL=https://your-project.supabase.co \ + --dart-define=SUPABASE_ANON_KEY=your_anon_key \ + --dart-define=SUPABASE_USE_PKCE=true + ``` 3. Install dependencies: ```bash diff --git a/lib/main.dart b/lib/main.dart index 050b0ba..bf926dc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -12,8 +12,18 @@ export 'package:supabase_flutter/supabase_flutter.dart' show AuthException, UserAttributes; // ── Supabase credentials ────────────────────────────────────────────── -const _supabaseUrl = 'https://yaopcyubateifnicpywp.supabase.co'; -const _supabaseAnonKey = 'sb_publishable_a7czIl7-TGeBJvid9z2XZA_3ElImliL'; +const _supabaseUrl = String.fromEnvironment( + 'SUPABASE_URL', + defaultValue: 'https://yaopcyubateifnicpywp.supabase.co', +); +const _supabaseAnonKey = String.fromEnvironment( + 'SUPABASE_ANON_KEY', + defaultValue: 'sb_publishable_a7czIl7-TGeBJvid9z2XZA_3ElImliL', +); +const _usePkceAuthFlow = bool.fromEnvironment( + 'SUPABASE_USE_PKCE', + defaultValue: true, +); Future main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -21,8 +31,10 @@ Future main() async { await Supabase.initialize( url: _supabaseUrl, anonKey: _supabaseAnonKey, - authOptions: const FlutterAuthClientOptions( - authFlowType: AuthFlowType.implicit, + authOptions: FlutterAuthClientOptions( + authFlowType: _usePkceAuthFlow + ? AuthFlowType.pkce + : AuthFlowType.implicit, ), );